/* EditingTools.c generated by valac 0.56.19, the Vala compiler
 * generated from EditingTools.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */
/* This file is the master unit file for the EditingTools unit.  It should be edited to include
 * whatever code is deemed necessary.
 *
 * The init() and terminate() methods are mandatory.
 *
 * If the unit needs to be configured prior to initialization, add the proper parameters to
 * the preconfigure() method, implement it, and ensure in init() that it's been called.
 */

#include <glib.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <gdk/gdk.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <cairo-gobject.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gobject/gvaluecollector.h>
#include <glib/gi18n-lib.h>
#include <gee.h>
#include "shotwell-graphics-processor.h"

#define EDITING_TOOLS_EDITING_TOOL_WINDOW_FRAME_BORDER 6
#define RESOURCES_TRANSIENT_WINDOW_OPACITY 0.90
#define RESOURCES_ONIMAGE_FONT_BACKGROUND "rgba(255,255,255,0.5)"
#define RESOURCES_ONIMAGE_FONT_COLOR "#000000"
#define EDITING_TOOLS_CROP_TOOL_CROP_INIT_X_PCT 0.15
#define EDITING_TOOLS_CROP_TOOL_CROP_INIT_Y_PCT 0.15
#define EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE 8
#define EDITING_TOOLS_CROP_TOOL_CROP_EXTERIOR_SATURATION 0.00f
#define EDITING_TOOLS_CROP_TOOL_CROP_EXTERIOR_RED_SHIFT -32
#define EDITING_TOOLS_CROP_TOOL_CROP_EXTERIOR_GREEN_SHIFT -32
#define EDITING_TOOLS_CROP_TOOL_CROP_EXTERIOR_BLUE_SHIFT -32
#define EDITING_TOOLS_CROP_TOOL_CROP_EXTERIOR_ALPHA_SHIFT 0
#define EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO (-1.0f)
#define EDITING_TOOLS_CROP_TOOL_SCREEN_ASPECT_RATIO (-2.0f)
#define EDITING_TOOLS_CROP_TOOL_ORIGINAL_ASPECT_RATIO (-3.0f)
#define EDITING_TOOLS_CROP_TOOL_CUSTOM_ASPECT_RATIO (-4.0f)
#define EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS (-5.0f)
#define EDITING_TOOLS_CROP_TOOL_SEPARATOR (-6.0f)
#define EDITING_TOOLS_CROP_TOOL_MIN_ASPECT_RATIO (1.0f / 64.0f)
#define EDITING_TOOLS_CROP_TOOL_MAX_ASPECT_RATIO 64.0f
#define RESOURCES_CROP_LABEL _ ("Crop")
#define RESOURCES_CROP_TOOLTIP _ ("Crop the photo’s size")
#define EDITING_TOOLS_CROP_TOOL_CROP_TOOL_WINDOW_CONTROL_SPACING 8
#define RESOURCES_CANCEL_LABEL _ ("_Cancel")
#define EDITING_TOOLS_REDEYE_INSTANCE_MIN_RADIUS 4
#define EDITING_TOOLS_REDEYE_INSTANCE_MAX_RADIUS 32
#define EDITING_TOOLS_REDEYE_INSTANCE_DEFAULT_RADIUS 10
#define RESOURCES_RED_EYE_LABEL _ ("Red-eye")
#define RESOURCES_RED_EYE_TOOLTIP _ ("Reduce or eliminate any red-eye effects in the photo")
#define EDITING_TOOLS_REDEYE_TOOL_REDEYE_TOOL_WINDOW_CONTROL_SPACING 8
#define RESOURCES_APPLY_LABEL _ ("_Apply")
#define EDITING_TOOLS_ADJUST_TOOL_SLIDER_WIDTH 200
#define EDITING_TOOLS_ADJUST_TOOL_SLIDER_DELAY_MSEC ((guint) 100)
#define RESOURCES_ADJUST_LABEL _ ("Adjust")
#define RESOURCES_ADJUST_TOOLTIP _ ("Adjust the photo’s color and tone")
#define RESOURCES_OK_LABEL _ ("_OK")
#define RESOURCES_ENHANCE_LABEL _ ("Enhance")
#define RESOURCES_ENHANCE_TOOLTIP _ ("Automatically improve the photo’s appearance")
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW (editing_tools_editing_tool_window_get_type ())
#define EDITING_TOOLS_EDITING_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow))
#define EDITING_TOOLS_EDITING_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindowClass))
#define EDITING_TOOLS_IS_EDITING_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW))
#define EDITING_TOOLS_IS_EDITING_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW))
#define EDITING_TOOLS_EDITING_TOOL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindowClass))

typedef struct _EditingToolsEditingToolWindow EditingToolsEditingToolWindow;
typedef struct _EditingToolsEditingToolWindowClass EditingToolsEditingToolWindowClass;
typedef struct _EditingToolsEditingToolWindowPrivate EditingToolsEditingToolWindowPrivate;
enum  {
	EDITING_TOOLS_EDITING_TOOL_WINDOW_0_PROPERTY,
	EDITING_TOOLS_EDITING_TOOL_WINDOW_NUM_PROPERTIES
};
static GParamSpec* editing_tools_editing_tool_window_properties[EDITING_TOOLS_EDITING_TOOL_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_PAGE_WINDOW (page_window_get_type ())
#define PAGE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PAGE_WINDOW, PageWindow))
#define PAGE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PAGE_WINDOW, PageWindowClass))
#define IS_PAGE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PAGE_WINDOW))
#define IS_PAGE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PAGE_WINDOW))
#define PAGE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PAGE_WINDOW, PageWindowClass))

typedef struct _PageWindow PageWindow;
typedef struct _PageWindowClass PageWindowClass;

#define TYPE_APP_WINDOW (app_window_get_type ())
#define APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_APP_WINDOW, AppWindow))
#define APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_APP_WINDOW, AppWindowClass))
#define IS_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_APP_WINDOW))
#define IS_APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_APP_WINDOW))
#define APP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_APP_WINDOW, AppWindowClass))

typedef struct _AppWindow AppWindow;
typedef struct _AppWindowClass AppWindowClass;

#define EDITING_TOOLS_TYPE_PHOTO_CANVAS (editing_tools_photo_canvas_get_type ())
#define EDITING_TOOLS_PHOTO_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_TYPE_PHOTO_CANVAS, EditingToolsPhotoCanvas))
#define EDITING_TOOLS_PHOTO_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_TYPE_PHOTO_CANVAS, EditingToolsPhotoCanvasClass))
#define EDITING_TOOLS_IS_PHOTO_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_TYPE_PHOTO_CANVAS))
#define EDITING_TOOLS_IS_PHOTO_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_TYPE_PHOTO_CANVAS))
#define EDITING_TOOLS_PHOTO_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_TYPE_PHOTO_CANVAS, EditingToolsPhotoCanvasClass))

typedef struct _EditingToolsPhotoCanvas EditingToolsPhotoCanvas;
typedef struct _EditingToolsPhotoCanvasClass EditingToolsPhotoCanvasClass;
typedef struct _EditingToolsPhotoCanvasPrivate EditingToolsPhotoCanvasPrivate;

#define TYPE_DATA_OBJECT (data_object_get_type ())
#define DATA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATA_OBJECT, DataObject))
#define DATA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATA_OBJECT, DataObjectClass))
#define IS_DATA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATA_OBJECT))
#define IS_DATA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATA_OBJECT))
#define DATA_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATA_OBJECT, DataObjectClass))

typedef struct _DataObject DataObject;
typedef struct _DataObjectClass DataObjectClass;

#define TYPE_DATA_SOURCE (data_source_get_type ())
#define DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATA_SOURCE, DataSource))
#define DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATA_SOURCE, DataSourceClass))
#define IS_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATA_SOURCE))
#define IS_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATA_SOURCE))
#define DATA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATA_SOURCE, DataSourceClass))

typedef struct _DataSource DataSource;
typedef struct _DataSourceClass DataSourceClass;

#define TYPE_THUMBNAIL_SOURCE (thumbnail_source_get_type ())
#define THUMBNAIL_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_THUMBNAIL_SOURCE, ThumbnailSource))
#define THUMBNAIL_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_THUMBNAIL_SOURCE, ThumbnailSourceClass))
#define IS_THUMBNAIL_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_THUMBNAIL_SOURCE))
#define IS_THUMBNAIL_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_THUMBNAIL_SOURCE))
#define THUMBNAIL_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_THUMBNAIL_SOURCE, ThumbnailSourceClass))

typedef struct _ThumbnailSource ThumbnailSource;
typedef struct _ThumbnailSourceClass ThumbnailSourceClass;

#define TYPE_MEDIA_SOURCE (media_source_get_type ())
#define MEDIA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MEDIA_SOURCE, MediaSource))
#define MEDIA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MEDIA_SOURCE, MediaSourceClass))
#define IS_MEDIA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MEDIA_SOURCE))
#define IS_MEDIA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MEDIA_SOURCE))
#define MEDIA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MEDIA_SOURCE, MediaSourceClass))

typedef struct _MediaSource MediaSource;
typedef struct _MediaSourceClass MediaSourceClass;

#define TYPE_PHOTO_SOURCE (photo_source_get_type ())
#define PHOTO_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO_SOURCE, PhotoSource))
#define PHOTO_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO_SOURCE, PhotoSourceClass))
#define IS_PHOTO_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO_SOURCE))
#define IS_PHOTO_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO_SOURCE))
#define PHOTO_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO_SOURCE, PhotoSourceClass))

typedef struct _PhotoSource PhotoSource;
typedef struct _PhotoSourceClass PhotoSourceClass;

#define TYPE_PHOTO (photo_get_type ())
#define PHOTO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO, Photo))
#define PHOTO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO, PhotoClass))
#define IS_PHOTO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO))
#define IS_PHOTO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO))
#define PHOTO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO, PhotoClass))

typedef struct _Photo Photo;
typedef struct _PhotoClass PhotoClass;

#define TYPE_DIMENSIONS (dimensions_get_type ())
typedef struct _Dimensions Dimensions;
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
typedef enum  {
	PHOTO_EXCEPTION_NONE = 0,
	PHOTO_EXCEPTION_ORIENTATION = 1 << 0,
	PHOTO_EXCEPTION_CROP = 1 << 1,
	PHOTO_EXCEPTION_REDEYE = 1 << 2,
	PHOTO_EXCEPTION_ADJUST = 1 << 3,
	PHOTO_EXCEPTION_STRAIGHTEN = 1 << 4,
	PHOTO_EXCEPTION_ALL = 0xFFFFFFFFLL
} PhotoException;

#define PHOTO_TYPE_EXCEPTION (photo_exception_get_type ())

#define TYPE_SCALING (scaling_get_type ())
typedef struct _Scaling Scaling;
typedef enum  {
	SCALE_CONSTRAINT_ORIGINAL,
	SCALE_CONSTRAINT_DIMENSIONS,
	SCALE_CONSTRAINT_WIDTH,
	SCALE_CONSTRAINT_HEIGHT,
	SCALE_CONSTRAINT_FILL_VIEWPORT
} ScaleConstraint;

#define TYPE_SCALE_CONSTRAINT (scale_constraint_get_type ())

#define TYPE_BOX (box_get_type ())
typedef struct _Box Box;
typedef struct _EditingToolsParamSpecPhotoCanvas EditingToolsParamSpecPhotoCanvas;
enum  {
	EDITING_TOOLS_PHOTO_CANVAS_NEW_SURFACE_SIGNAL,
	EDITING_TOOLS_PHOTO_CANVAS_RESIZED_SCALED_PIXBUF_SIGNAL,
	EDITING_TOOLS_PHOTO_CANVAS_NUM_SIGNALS
};
static guint editing_tools_photo_canvas_signals[EDITING_TOOLS_PHOTO_CANVAS_NUM_SIGNALS] = {0};

#define EDITING_TOOLS_TYPE_EDITING_TOOL (editing_tools_editing_tool_get_type ())
#define EDITING_TOOLS_EDITING_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool))
#define EDITING_TOOLS_EDITING_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingToolClass))
#define EDITING_TOOLS_IS_EDITING_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_TYPE_EDITING_TOOL))
#define EDITING_TOOLS_IS_EDITING_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_TYPE_EDITING_TOOL))
#define EDITING_TOOLS_EDITING_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingToolClass))

typedef struct _EditingToolsEditingTool EditingToolsEditingTool;
typedef struct _EditingToolsEditingToolClass EditingToolsEditingToolClass;
typedef struct _EditingToolsEditingToolPrivate EditingToolsEditingToolPrivate;
#define _editing_tools_photo_canvas_unref0(var) ((var == NULL) ? NULL : (var = (editing_tools_photo_canvas_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_COMMAND (command_get_type ())
#define COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMMAND, Command))
#define COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMMAND, CommandClass))
#define IS_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMMAND))
#define IS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMMAND))
#define COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMMAND, CommandClass))

typedef struct _Command Command;
typedef struct _CommandClass CommandClass;
typedef EditingToolsEditingTool* (*EditingToolsEditingToolFactory) (void);
typedef struct _EditingToolsParamSpecEditingTool EditingToolsParamSpecEditingTool;
enum  {
	EDITING_TOOLS_EDITING_TOOL_ACTIVATED_SIGNAL,
	EDITING_TOOLS_EDITING_TOOL_DEACTIVATED_SIGNAL,
	EDITING_TOOLS_EDITING_TOOL_APPLIED_SIGNAL,
	EDITING_TOOLS_EDITING_TOOL_CANCELLED_SIGNAL,
	EDITING_TOOLS_EDITING_TOOL_ABORTED_SIGNAL,
	EDITING_TOOLS_EDITING_TOOL_NUM_SIGNALS
};
static guint editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_NUM_SIGNALS] = {0};

#define EDITING_TOOLS_TYPE_CROP_TOOL (editing_tools_crop_tool_get_type ())
#define EDITING_TOOLS_CROP_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool))
#define EDITING_TOOLS_CROP_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropToolClass))
#define EDITING_TOOLS_IS_CROP_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_TYPE_CROP_TOOL))
#define EDITING_TOOLS_IS_CROP_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_TYPE_CROP_TOOL))
#define EDITING_TOOLS_CROP_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropToolClass))

typedef struct _EditingToolsCropTool EditingToolsCropTool;
typedef struct _EditingToolsCropToolClass EditingToolsCropToolClass;
typedef struct _EditingToolsCropToolPrivate EditingToolsCropToolPrivate;

#define EDITING_TOOLS_CROP_TOOL_TYPE_CROP_TOOL_WINDOW (editing_tools_crop_tool_crop_tool_window_get_type ())
#define EDITING_TOOLS_CROP_TOOL_CROP_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_CROP_TOOL_TYPE_CROP_TOOL_WINDOW, EditingToolsCropToolCropToolWindow))
#define EDITING_TOOLS_CROP_TOOL_CROP_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_CROP_TOOL_TYPE_CROP_TOOL_WINDOW, EditingToolsCropToolCropToolWindowClass))
#define EDITING_TOOLS_CROP_TOOL_IS_CROP_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_CROP_TOOL_TYPE_CROP_TOOL_WINDOW))
#define EDITING_TOOLS_CROP_TOOL_IS_CROP_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_CROP_TOOL_TYPE_CROP_TOOL_WINDOW))
#define EDITING_TOOLS_CROP_TOOL_CROP_TOOL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_CROP_TOOL_TYPE_CROP_TOOL_WINDOW, EditingToolsCropToolCropToolWindowClass))

typedef struct _EditingToolsCropToolCropToolWindow EditingToolsCropToolCropToolWindow;
typedef struct _EditingToolsCropToolCropToolWindowClass EditingToolsCropToolCropToolWindowClass;
typedef enum  {
	BOX_LOCATION_OUTSIDE,
	BOX_LOCATION_INSIDE,
	BOX_LOCATION_TOP_SIDE,
	BOX_LOCATION_LEFT_SIDE,
	BOX_LOCATION_RIGHT_SIDE,
	BOX_LOCATION_BOTTOM_SIDE,
	BOX_LOCATION_TOP_LEFT,
	BOX_LOCATION_BOTTOM_LEFT,
	BOX_LOCATION_TOP_RIGHT,
	BOX_LOCATION_BOTTOM_RIGHT
} BoxLocation;

#define TYPE_BOX_LOCATION (box_location_get_type ())

#define EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION (editing_tools_crop_tool_constraint_description_get_type ())
#define EDITING_TOOLS_CROP_TOOL_CONSTRAINT_DESCRIPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION, EditingToolsCropToolConstraintDescription))
#define EDITING_TOOLS_CROP_TOOL_CONSTRAINT_DESCRIPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION, EditingToolsCropToolConstraintDescriptionClass))
#define EDITING_TOOLS_CROP_TOOL_IS_CONSTRAINT_DESCRIPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION))
#define EDITING_TOOLS_CROP_TOOL_IS_CONSTRAINT_DESCRIPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION))
#define EDITING_TOOLS_CROP_TOOL_CONSTRAINT_DESCRIPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION, EditingToolsCropToolConstraintDescriptionClass))

typedef struct _EditingToolsCropToolConstraintDescription EditingToolsCropToolConstraintDescription;
typedef struct _EditingToolsCropToolConstraintDescriptionClass EditingToolsCropToolConstraintDescriptionClass;
typedef enum  {
	EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_LANDSCAPE,
	EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_PORTRAIT
} EditingToolsCropToolReticleOrientation;

#define EDITING_TOOLS_CROP_TOOL_TYPE_RETICLE_ORIENTATION (editing_tools_crop_tool_reticle_orientation_get_type ())
typedef enum  {
	EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_NORMAL,
	EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_CUSTOM
} EditingToolsCropToolConstraintMode;

#define EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_MODE (editing_tools_crop_tool_constraint_mode_get_type ())
typedef struct _EditingToolsCropToolConstraintDescriptionPrivate EditingToolsCropToolConstraintDescriptionPrivate;
#define _editing_tools_crop_tool_constraint_description_unref0(var) ((var == NULL) ? NULL : (var = (editing_tools_crop_tool_constraint_description_unref (var), NULL)))
typedef struct _EditingToolsCropToolCropToolWindowPrivate EditingToolsCropToolCropToolWindowPrivate;

#define TYPE_CONFIGURATION_FACADE (configuration_facade_get_type ())
#define CONFIGURATION_FACADE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONFIGURATION_FACADE, ConfigurationFacade))
#define CONFIGURATION_FACADE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONFIGURATION_FACADE, ConfigurationFacadeClass))
#define IS_CONFIGURATION_FACADE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONFIGURATION_FACADE))
#define IS_CONFIGURATION_FACADE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONFIGURATION_FACADE))
#define CONFIGURATION_FACADE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONFIGURATION_FACADE, ConfigurationFacadeClass))

typedef struct _ConfigurationFacade ConfigurationFacade;
typedef struct _ConfigurationFacadeClass ConfigurationFacadeClass;

#define CONFIG_TYPE_FACADE (config_facade_get_type ())
#define CONFIG_FACADE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONFIG_TYPE_FACADE, ConfigFacade))
#define CONFIG_FACADE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONFIG_TYPE_FACADE, ConfigFacadeClass))
#define CONFIG_IS_FACADE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONFIG_TYPE_FACADE))
#define CONFIG_IS_FACADE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONFIG_TYPE_FACADE))
#define CONFIG_FACADE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONFIG_TYPE_FACADE, ConfigFacadeClass))

typedef struct _ConfigFacade ConfigFacade;
typedef struct _ConfigFacadeClass ConfigFacadeClass;
typedef enum  {
	BACKING_FETCH_MODE_SOURCE,
	BACKING_FETCH_MODE_BASELINE,
	BACKING_FETCH_MODE_MASTER,
	BACKING_FETCH_MODE_UNMODIFIED
} BackingFetchMode;

#define TYPE_BACKING_FETCH_MODE (backing_fetch_mode_get_type ())

#define TYPE_PAGE_COMMAND (page_command_get_type ())
#define PAGE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PAGE_COMMAND, PageCommand))
#define PAGE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PAGE_COMMAND, PageCommandClass))
#define IS_PAGE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PAGE_COMMAND))
#define IS_PAGE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PAGE_COMMAND))
#define PAGE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PAGE_COMMAND, PageCommandClass))

typedef struct _PageCommand PageCommand;
typedef struct _PageCommandClass PageCommandClass;

#define TYPE_SINGLE_DATA_SOURCE_COMMAND (single_data_source_command_get_type ())
#define SINGLE_DATA_SOURCE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SINGLE_DATA_SOURCE_COMMAND, SingleDataSourceCommand))
#define SINGLE_DATA_SOURCE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SINGLE_DATA_SOURCE_COMMAND, SingleDataSourceCommandClass))
#define IS_SINGLE_DATA_SOURCE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SINGLE_DATA_SOURCE_COMMAND))
#define IS_SINGLE_DATA_SOURCE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SINGLE_DATA_SOURCE_COMMAND))
#define SINGLE_DATA_SOURCE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SINGLE_DATA_SOURCE_COMMAND, SingleDataSourceCommandClass))

typedef struct _SingleDataSourceCommand SingleDataSourceCommand;
typedef struct _SingleDataSourceCommandClass SingleDataSourceCommandClass;

#define TYPE_GENERIC_PHOTO_TRANSFORMATION_COMMAND (generic_photo_transformation_command_get_type ())
#define GENERIC_PHOTO_TRANSFORMATION_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GENERIC_PHOTO_TRANSFORMATION_COMMAND, GenericPhotoTransformationCommand))
#define GENERIC_PHOTO_TRANSFORMATION_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GENERIC_PHOTO_TRANSFORMATION_COMMAND, GenericPhotoTransformationCommandClass))
#define IS_GENERIC_PHOTO_TRANSFORMATION_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GENERIC_PHOTO_TRANSFORMATION_COMMAND))
#define IS_GENERIC_PHOTO_TRANSFORMATION_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GENERIC_PHOTO_TRANSFORMATION_COMMAND))
#define GENERIC_PHOTO_TRANSFORMATION_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GENERIC_PHOTO_TRANSFORMATION_COMMAND, GenericPhotoTransformationCommandClass))

typedef struct _GenericPhotoTransformationCommand GenericPhotoTransformationCommand;
typedef struct _GenericPhotoTransformationCommandClass GenericPhotoTransformationCommandClass;

#define TYPE_CROP_COMMAND (crop_command_get_type ())
#define CROP_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CROP_COMMAND, CropCommand))
#define CROP_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CROP_COMMAND, CropCommandClass))
#define IS_CROP_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CROP_COMMAND))
#define IS_CROP_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CROP_COMMAND))
#define CROP_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CROP_COMMAND, CropCommandClass))

typedef struct _CropCommand CropCommand;
typedef struct _CropCommandClass CropCommandClass;
typedef enum  {
	BOX_COMPLEMENTS_NONE,
	BOX_COMPLEMENTS_VERTICAL,
	BOX_COMPLEMENTS_HORIZONTAL,
	BOX_COMPLEMENTS_BOTH
} BoxComplements;

#define TYPE_BOX_COMPLEMENTS (box_complements_get_type ())
typedef struct _EditingToolsCropToolParamSpecConstraintDescription EditingToolsCropToolParamSpecConstraintDescription;
enum  {
	EDITING_TOOLS_CROP_TOOL_CROP_TOOL_WINDOW_0_PROPERTY,
	EDITING_TOOLS_CROP_TOOL_CROP_TOOL_WINDOW_NUM_PROPERTIES
};
static GParamSpec* editing_tools_crop_tool_crop_tool_window_properties[EDITING_TOOLS_CROP_TOOL_CROP_TOOL_WINDOW_NUM_PROPERTIES];

#define EDITING_TOOLS_TYPE_REDEYE_INSTANCE (editing_tools_redeye_instance_get_type ())
typedef struct _EditingToolsRedeyeInstance EditingToolsRedeyeInstance;

#define EDITING_TOOLS_TYPE_REDEYE_TOOL (editing_tools_redeye_tool_get_type ())
#define EDITING_TOOLS_REDEYE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool))
#define EDITING_TOOLS_REDEYE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeToolClass))
#define EDITING_TOOLS_IS_REDEYE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_TYPE_REDEYE_TOOL))
#define EDITING_TOOLS_IS_REDEYE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_TYPE_REDEYE_TOOL))
#define EDITING_TOOLS_REDEYE_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeToolClass))

typedef struct _EditingToolsRedeyeTool EditingToolsRedeyeTool;
typedef struct _EditingToolsRedeyeToolClass EditingToolsRedeyeToolClass;
typedef struct _EditingToolsRedeyeToolPrivate EditingToolsRedeyeToolPrivate;

#define EDITING_TOOLS_REDEYE_TOOL_TYPE_REDEYE_TOOL_WINDOW (editing_tools_redeye_tool_redeye_tool_window_get_type ())
#define EDITING_TOOLS_REDEYE_TOOL_REDEYE_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_REDEYE_TOOL_TYPE_REDEYE_TOOL_WINDOW, EditingToolsRedeyeToolRedeyeToolWindow))
#define EDITING_TOOLS_REDEYE_TOOL_REDEYE_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_REDEYE_TOOL_TYPE_REDEYE_TOOL_WINDOW, EditingToolsRedeyeToolRedeyeToolWindowClass))
#define EDITING_TOOLS_REDEYE_TOOL_IS_REDEYE_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_REDEYE_TOOL_TYPE_REDEYE_TOOL_WINDOW))
#define EDITING_TOOLS_REDEYE_TOOL_IS_REDEYE_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_REDEYE_TOOL_TYPE_REDEYE_TOOL_WINDOW))
#define EDITING_TOOLS_REDEYE_TOOL_REDEYE_TOOL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_REDEYE_TOOL_TYPE_REDEYE_TOOL_WINDOW, EditingToolsRedeyeToolRedeyeToolWindowClass))

typedef struct _EditingToolsRedeyeToolRedeyeToolWindow EditingToolsRedeyeToolRedeyeToolWindow;
typedef struct _EditingToolsRedeyeToolRedeyeToolWindowClass EditingToolsRedeyeToolRedeyeToolWindowClass;
typedef struct _EditingToolsRedeyeToolRedeyeToolWindowPrivate EditingToolsRedeyeToolRedeyeToolWindowPrivate;

#define TYPE_REDEYE_COMMAND (redeye_command_get_type ())
#define REDEYE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_REDEYE_COMMAND, RedeyeCommand))
#define REDEYE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_REDEYE_COMMAND, RedeyeCommandClass))
#define IS_REDEYE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_REDEYE_COMMAND))
#define IS_REDEYE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_REDEYE_COMMAND))
#define REDEYE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_REDEYE_COMMAND, RedeyeCommandClass))

typedef struct _RedeyeCommand RedeyeCommand;
typedef struct _RedeyeCommandClass RedeyeCommandClass;

#define TYPE_COMMAND_MANAGER (command_manager_get_type ())
#define COMMAND_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMMAND_MANAGER, CommandManager))
#define COMMAND_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMMAND_MANAGER, CommandManagerClass))
#define IS_COMMAND_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMMAND_MANAGER))
#define IS_COMMAND_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMMAND_MANAGER))
#define COMMAND_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMMAND_MANAGER, CommandManagerClass))

typedef struct _CommandManager CommandManager;
typedef struct _CommandManagerClass CommandManagerClass;
#define _command_manager_unref0(var) ((var == NULL) ? NULL : (var = (command_manager_unref (var), NULL)))

#define TYPE_ALTERATION (alteration_get_type ())
#define ALTERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ALTERATION, Alteration))
#define ALTERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ALTERATION, AlterationClass))
#define IS_ALTERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ALTERATION))
#define IS_ALTERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ALTERATION))
#define ALTERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ALTERATION, AlterationClass))

typedef struct _Alteration Alteration;
typedef struct _AlterationClass AlterationClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define TYPE_DATA_COLLECTION (data_collection_get_type ())
#define DATA_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATA_COLLECTION, DataCollection))
#define DATA_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATA_COLLECTION, DataCollectionClass))
#define IS_DATA_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATA_COLLECTION))
#define IS_DATA_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATA_COLLECTION))
#define DATA_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATA_COLLECTION, DataCollectionClass))

typedef struct _DataCollection DataCollection;
typedef struct _DataCollectionClass DataCollectionClass;
#define _data_collection_unref0(var) ((var == NULL) ? NULL : (var = (data_collection_unref (var), NULL)))
enum  {
	EDITING_TOOLS_REDEYE_TOOL_REDEYE_TOOL_WINDOW_0_PROPERTY,
	EDITING_TOOLS_REDEYE_TOOL_REDEYE_TOOL_WINDOW_NUM_PROPERTIES
};
static GParamSpec* editing_tools_redeye_tool_redeye_tool_window_properties[EDITING_TOOLS_REDEYE_TOOL_REDEYE_TOOL_WINDOW_NUM_PROPERTIES];

#define EDITING_TOOLS_TYPE_ADJUST_TOOL (editing_tools_adjust_tool_get_type ())
#define EDITING_TOOLS_ADJUST_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustTool))
#define EDITING_TOOLS_ADJUST_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustToolClass))
#define EDITING_TOOLS_IS_ADJUST_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_TYPE_ADJUST_TOOL))
#define EDITING_TOOLS_IS_ADJUST_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_TYPE_ADJUST_TOOL))
#define EDITING_TOOLS_ADJUST_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustToolClass))

typedef struct _EditingToolsAdjustTool EditingToolsAdjustTool;
typedef struct _EditingToolsAdjustToolClass EditingToolsAdjustToolClass;
typedef struct _EditingToolsAdjustToolPrivate EditingToolsAdjustToolPrivate;

#define EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_WINDOW (editing_tools_adjust_tool_adjust_tool_window_get_type ())
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_WINDOW, EditingToolsAdjustToolAdjustToolWindow))
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_WINDOW, EditingToolsAdjustToolAdjustToolWindowClass))
#define EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_WINDOW))
#define EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_WINDOW))
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_WINDOW, EditingToolsAdjustToolAdjustToolWindowClass))

typedef struct _EditingToolsAdjustToolAdjustToolWindow EditingToolsAdjustToolAdjustToolWindow;
typedef struct _EditingToolsAdjustToolAdjustToolWindowClass EditingToolsAdjustToolAdjustToolWindowClass;

#define TYPE_ONE_SHOT_SCHEDULER (one_shot_scheduler_get_type ())
#define ONE_SHOT_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ONE_SHOT_SCHEDULER, OneShotScheduler))
#define ONE_SHOT_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ONE_SHOT_SCHEDULER, OneShotSchedulerClass))
#define IS_ONE_SHOT_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ONE_SHOT_SCHEDULER))
#define IS_ONE_SHOT_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ONE_SHOT_SCHEDULER))
#define ONE_SHOT_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ONE_SHOT_SCHEDULER, OneShotSchedulerClass))

typedef struct _OneShotScheduler OneShotScheduler;
typedef struct _OneShotSchedulerClass OneShotSchedulerClass;
#define _pixel_transformer_unref0(var) ((var == NULL) ? NULL : (var = (pixel_transformer_unref (var), NULL)))
#define _pixel_transformation_bundle_unref0(var) ((var == NULL) ? NULL : (var = (pixel_transformation_bundle_unref (var), NULL)))
#define _one_shot_scheduler_unref0(var) ((var == NULL) ? NULL : (var = (one_shot_scheduler_unref (var), NULL)))
typedef struct _EditingToolsAdjustToolAdjustToolWindowPrivate EditingToolsAdjustToolAdjustToolWindowPrivate;

#define TYPE_RGB_HISTOGRAM_MANIPULATOR (rgb_histogram_manipulator_get_type ())
#define RGB_HISTOGRAM_MANIPULATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RGB_HISTOGRAM_MANIPULATOR, RGBHistogramManipulator))
#define RGB_HISTOGRAM_MANIPULATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RGB_HISTOGRAM_MANIPULATOR, RGBHistogramManipulatorClass))
#define IS_RGB_HISTOGRAM_MANIPULATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RGB_HISTOGRAM_MANIPULATOR))
#define IS_RGB_HISTOGRAM_MANIPULATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RGB_HISTOGRAM_MANIPULATOR))
#define RGB_HISTOGRAM_MANIPULATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RGB_HISTOGRAM_MANIPULATOR, RGBHistogramManipulatorClass))

typedef struct _RGBHistogramManipulator RGBHistogramManipulator;
typedef struct _RGBHistogramManipulatorClass RGBHistogramManipulatorClass;
#define _pixel_transformation_unref0(var) ((var == NULL) ? NULL : (var = (pixel_transformation_unref (var), NULL)))

#define EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND (editing_tools_adjust_tool_adjust_tool_command_get_type ())
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand))
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommandClass))
#define EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_TOOL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND))
#define EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_TOOL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND))
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommandClass))

typedef struct _EditingToolsAdjustToolAdjustToolCommand EditingToolsAdjustToolAdjustToolCommand;
typedef struct _EditingToolsAdjustToolAdjustToolCommandClass EditingToolsAdjustToolAdjustToolCommandClass;

#define EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND (editing_tools_adjust_tool_adjust_reset_command_get_type ())
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_RESET_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND, EditingToolsAdjustToolAdjustResetCommand))
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_RESET_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND, EditingToolsAdjustToolAdjustResetCommandClass))
#define EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_RESET_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND))
#define EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_RESET_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND))
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_RESET_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND, EditingToolsAdjustToolAdjustResetCommandClass))

typedef struct _EditingToolsAdjustToolAdjustResetCommand EditingToolsAdjustToolAdjustResetCommand;
typedef struct _EditingToolsAdjustToolAdjustResetCommandClass EditingToolsAdjustToolAdjustResetCommandClass;

#define TYPE_ADJUST_COLORS_SINGLE_COMMAND (adjust_colors_single_command_get_type ())
#define ADJUST_COLORS_SINGLE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ADJUST_COLORS_SINGLE_COMMAND, AdjustColorsSingleCommand))
#define ADJUST_COLORS_SINGLE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ADJUST_COLORS_SINGLE_COMMAND, AdjustColorsSingleCommandClass))
#define IS_ADJUST_COLORS_SINGLE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ADJUST_COLORS_SINGLE_COMMAND))
#define IS_ADJUST_COLORS_SINGLE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ADJUST_COLORS_SINGLE_COMMAND))
#define ADJUST_COLORS_SINGLE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ADJUST_COLORS_SINGLE_COMMAND, AdjustColorsSingleCommandClass))

typedef struct _AdjustColorsSingleCommand AdjustColorsSingleCommand;
typedef struct _AdjustColorsSingleCommandClass AdjustColorsSingleCommandClass;

#define EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND (editing_tools_adjust_tool_slider_adjustment_command_get_type ())
#define EDITING_TOOLS_ADJUST_TOOL_SLIDER_ADJUSTMENT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND, EditingToolsAdjustToolSliderAdjustmentCommand))
#define EDITING_TOOLS_ADJUST_TOOL_SLIDER_ADJUSTMENT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND, EditingToolsAdjustToolSliderAdjustmentCommandClass))
#define EDITING_TOOLS_ADJUST_TOOL_IS_SLIDER_ADJUSTMENT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND))
#define EDITING_TOOLS_ADJUST_TOOL_IS_SLIDER_ADJUSTMENT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND))
#define EDITING_TOOLS_ADJUST_TOOL_SLIDER_ADJUSTMENT_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND, EditingToolsAdjustToolSliderAdjustmentCommandClass))

typedef struct _EditingToolsAdjustToolSliderAdjustmentCommand EditingToolsAdjustToolSliderAdjustmentCommand;
typedef struct _EditingToolsAdjustToolSliderAdjustmentCommandClass EditingToolsAdjustToolSliderAdjustmentCommandClass;
typedef void (*OneShotCallback) (gpointer user_data);

#define EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND (editing_tools_adjust_tool_adjust_enhance_command_get_type ())
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_ENHANCE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND, EditingToolsAdjustToolAdjustEnhanceCommand))
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_ENHANCE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND, EditingToolsAdjustToolAdjustEnhanceCommandClass))
#define EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_ENHANCE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND))
#define EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_ENHANCE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND))
#define EDITING_TOOLS_ADJUST_TOOL_ADJUST_ENHANCE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND, EditingToolsAdjustToolAdjustEnhanceCommandClass))

typedef struct _EditingToolsAdjustToolAdjustEnhanceCommand EditingToolsAdjustToolAdjustEnhanceCommand;
typedef struct _EditingToolsAdjustToolAdjustEnhanceCommandClass EditingToolsAdjustToolAdjustEnhanceCommandClass;
enum  {
	EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_WINDOW_0_PROPERTY,
	EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_WINDOW_NUM_PROPERTIES
};
static GParamSpec* editing_tools_adjust_tool_adjust_tool_window_properties[EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_WINDOW_NUM_PROPERTIES];

#define TYPE_COMMAND_DESCRIPTION (command_description_get_type ())
#define COMMAND_DESCRIPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMMAND_DESCRIPTION, CommandDescription))
#define IS_COMMAND_DESCRIPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMMAND_DESCRIPTION))
#define COMMAND_DESCRIPTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_COMMAND_DESCRIPTION, CommandDescriptionIface))

typedef struct _CommandDescription CommandDescription;
typedef struct _CommandDescriptionIface CommandDescriptionIface;
typedef struct _CommandPrivate CommandPrivate;
typedef struct _EditingToolsAdjustToolAdjustToolCommandPrivate EditingToolsAdjustToolAdjustToolCommandPrivate;
enum  {
	EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_COMMAND_0_PROPERTY,
	EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_COMMAND_NUM_PROPERTIES
};
static GParamSpec* editing_tools_adjust_tool_adjust_tool_command_properties[EDITING_TOOLS_ADJUST_TOOL_ADJUST_TOOL_COMMAND_NUM_PROPERTIES];
typedef struct _EditingToolsAdjustToolAdjustResetCommandPrivate EditingToolsAdjustToolAdjustResetCommandPrivate;
enum  {
	EDITING_TOOLS_ADJUST_TOOL_ADJUST_RESET_COMMAND_0_PROPERTY,
	EDITING_TOOLS_ADJUST_TOOL_ADJUST_RESET_COMMAND_NUM_PROPERTIES
};
static GParamSpec* editing_tools_adjust_tool_adjust_reset_command_properties[EDITING_TOOLS_ADJUST_TOOL_ADJUST_RESET_COMMAND_NUM_PROPERTIES];
typedef struct _EditingToolsAdjustToolSliderAdjustmentCommandPrivate EditingToolsAdjustToolSliderAdjustmentCommandPrivate;
enum  {
	EDITING_TOOLS_ADJUST_TOOL_SLIDER_ADJUSTMENT_COMMAND_0_PROPERTY,
	EDITING_TOOLS_ADJUST_TOOL_SLIDER_ADJUSTMENT_COMMAND_NUM_PROPERTIES
};
static GParamSpec* editing_tools_adjust_tool_slider_adjustment_command_properties[EDITING_TOOLS_ADJUST_TOOL_SLIDER_ADJUSTMENT_COMMAND_NUM_PROPERTIES];
typedef struct _EditingToolsAdjustToolAdjustEnhanceCommandPrivate EditingToolsAdjustToolAdjustEnhanceCommandPrivate;
enum  {
	EDITING_TOOLS_ADJUST_TOOL_ADJUST_ENHANCE_COMMAND_0_PROPERTY,
	EDITING_TOOLS_ADJUST_TOOL_ADJUST_ENHANCE_COMMAND_NUM_PROPERTIES
};
static GParamSpec* editing_tools_adjust_tool_adjust_enhance_command_properties[EDITING_TOOLS_ADJUST_TOOL_ADJUST_ENHANCE_COMMAND_NUM_PROPERTIES];

#define TYPE_ENHANCE_SINGLE_COMMAND (enhance_single_command_get_type ())
#define ENHANCE_SINGLE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ENHANCE_SINGLE_COMMAND, EnhanceSingleCommand))
#define ENHANCE_SINGLE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ENHANCE_SINGLE_COMMAND, EnhanceSingleCommandClass))
#define IS_ENHANCE_SINGLE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ENHANCE_SINGLE_COMMAND))
#define IS_ENHANCE_SINGLE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ENHANCE_SINGLE_COMMAND))
#define ENHANCE_SINGLE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ENHANCE_SINGLE_COMMAND, EnhanceSingleCommandClass))

typedef struct _EnhanceSingleCommand EnhanceSingleCommand;
typedef struct _EnhanceSingleCommandClass EnhanceSingleCommandClass;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _EditingToolsEditingToolWindow {
	GtkWindow parent_instance;
	EditingToolsEditingToolWindowPrivate * priv;
};

struct _EditingToolsEditingToolWindowClass {
	GtkWindowClass parent_class;
};

struct _EditingToolsEditingToolWindowPrivate {
	GtkFrame* layout_frame;
	gboolean user_moved;
};

struct _EditingToolsPhotoCanvas {
	GTypeInstance parent_instance;
	volatile int ref_count;
	EditingToolsPhotoCanvasPrivate * priv;
};

struct _EditingToolsPhotoCanvasClass {
	GTypeClass parent_class;
	void (*finalize) (EditingToolsPhotoCanvas *self);
	void (*repaint) (EditingToolsPhotoCanvas* self);
};

struct _Dimensions {
	gint width;
	gint height;
};

struct _EditingToolsPhotoCanvasPrivate {
	GtkWindow* container;
	GdkWindow* drawing_window;
	Photo* photo;
	cairo_t* default_ctx;
	Dimensions surface_dim;
	cairo_surface_t* scaled;
	GdkPixbuf* scaled_pixbuf;
	GdkRectangle scaled_position;
};

struct _Scaling {
	ScaleConstraint constraint;
	gint scale;
	Dimensions viewport;
	gboolean scale_up;
};

struct _Box {
	gint left;
	gint top;
	gint right;
	gint bottom;
};

struct _EditingToolsParamSpecPhotoCanvas {
	GParamSpec parent_instance;
};

struct _EditingToolsEditingTool {
	GTypeInstance parent_instance;
	volatile int ref_count;
	EditingToolsEditingToolPrivate * priv;
	EditingToolsPhotoCanvas* canvas;
	cairo_surface_t* surface;
	gchar* name;
};

struct _EditingToolsEditingToolClass {
	GTypeClass parent_class;
	void (*finalize) (EditingToolsEditingTool *self);
	void (*activate) (EditingToolsEditingTool* self, EditingToolsPhotoCanvas* canvas);
	void (*deactivate) (EditingToolsEditingTool* self);
	EditingToolsEditingToolWindow* (*get_tool_window) (EditingToolsEditingTool* self);
	GdkPixbuf* (*get_display_pixbuf) (EditingToolsEditingTool* self, Scaling* scaling, Photo* photo, Dimensions* max_dim, GError** error);
	void (*on_left_click) (EditingToolsEditingTool* self, gint x, gint y);
	void (*on_left_released) (EditingToolsEditingTool* self, gint x, gint y);
	void (*on_motion) (EditingToolsEditingTool* self, gint x, gint y, GdkModifierType mask);
	gboolean (*on_leave_notify_event) (EditingToolsEditingTool* self);
	gboolean (*on_keypress) (EditingToolsEditingTool* self, GdkEventKey* event);
	void (*paint) (EditingToolsEditingTool* self, cairo_t* ctx);
};

struct _EditingToolsEditingToolPrivate {
	EditingToolsEditingToolWindow* tool_window;
};

struct _EditingToolsParamSpecEditingTool {
	GParamSpec parent_instance;
};

struct _EditingToolsCropTool {
	EditingToolsEditingTool parent_instance;
	EditingToolsCropToolPrivate * priv;
};

struct _EditingToolsCropToolClass {
	EditingToolsEditingToolClass parent_class;
};

struct _EditingToolsCropToolPrivate {
	EditingToolsCropToolCropToolWindow* crop_tool_window;
	GdkCursorType current_cursor_type;
	BoxLocation in_manipulation;
	cairo_t* wide_black_ctx;
	cairo_t* wide_white_ctx;
	cairo_t* thin_white_ctx;
	cairo_t* text_ctx;
	cairo_surface_t* crop_surface;
	Box scaled_crop;
	gint last_grab_x;
	gint last_grab_y;
	EditingToolsCropToolConstraintDescription** constraints;
	gint constraints_length1;
	gint _constraints_size_;
	GtkListStore* constraint_list;
	EditingToolsCropToolReticleOrientation reticle_orientation;
	EditingToolsCropToolConstraintMode constraint_mode;
	gboolean entry_insert_in_progress;
	gfloat custom_aspect_ratio;
	gint custom_width;
	gint custom_height;
	gint custom_init_width;
	gint custom_init_height;
	gfloat pre_aspect_ratio;
};

struct _EditingToolsCropToolConstraintDescription {
	GTypeInstance parent_instance;
	volatile int ref_count;
	EditingToolsCropToolConstraintDescriptionPrivate * priv;
	gchar* name;
	gint basis_width;
	gint basis_height;
	gboolean is_pivotable;
	gfloat aspect_ratio;
};

struct _EditingToolsCropToolConstraintDescriptionClass {
	GTypeClass parent_class;
	void (*finalize) (EditingToolsCropToolConstraintDescription *self);
};

struct _EditingToolsCropToolCropToolWindow {
	EditingToolsEditingToolWindow parent_instance;
	EditingToolsCropToolCropToolWindowPrivate * priv;
	GtkButton* ok_button;
	GtkButton* cancel_button;
	GtkComboBox* constraint_combo;
	GtkButton* pivot_reticle_button;
	GtkEntry* custom_width_entry;
	GtkEntry* custom_height_entry;
	GtkLabel* custom_mulsign_label;
	GtkEntry* most_recently_edited;
	GtkBox* response_layout;
	GtkBox* layout;
	gint normal_width;
	gint normal_height;
};

struct _EditingToolsCropToolCropToolWindowClass {
	EditingToolsEditingToolWindowClass parent_class;
};

struct _EditingToolsCropToolParamSpecConstraintDescription {
	GParamSpec parent_instance;
};

struct _EditingToolsRedeyeInstance {
	GdkPoint center;
	gint radius;
};

struct _EditingToolsRedeyeTool {
	EditingToolsEditingTool parent_instance;
	EditingToolsRedeyeToolPrivate * priv;
};

struct _EditingToolsRedeyeToolClass {
	EditingToolsEditingToolClass parent_class;
};

struct _EditingToolsRedeyeToolPrivate {
	cairo_t* thin_white_ctx;
	cairo_t* wider_gray_ctx;
	EditingToolsRedeyeToolRedeyeToolWindow* redeye_tool_window;
	EditingToolsRedeyeInstance user_interaction_instance;
	gboolean is_reticle_move_in_progress;
	GdkPoint reticle_move_mouse_start_point;
	GdkPoint reticle_move_anchor;
	GdkRectangle old_scaled_pixbuf_position;
	GdkPixbuf* current_pixbuf;
};

struct _EditingToolsRedeyeToolRedeyeToolWindow {
	EditingToolsEditingToolWindow parent_instance;
	EditingToolsRedeyeToolRedeyeToolWindowPrivate * priv;
	GtkButton* apply_button;
	GtkButton* close_button;
	GtkScale* slider;
};

struct _EditingToolsRedeyeToolRedeyeToolWindowClass {
	EditingToolsEditingToolWindowClass parent_class;
};

struct _EditingToolsRedeyeToolRedeyeToolWindowPrivate {
	GtkLabel* slider_label;
};

struct _EditingToolsAdjustTool {
	EditingToolsEditingTool parent_instance;
	EditingToolsAdjustToolPrivate * priv;
};

struct _EditingToolsAdjustToolClass {
	EditingToolsEditingToolClass parent_class;
};

struct _EditingToolsAdjustToolPrivate {
	EditingToolsAdjustToolAdjustToolWindow* adjust_tool_window;
	gboolean suppress_effect_redraw;
	GdkPixbuf* draw_to_pixbuf;
	GdkPixbuf* histogram_pixbuf;
	GdkPixbuf* virgin_histogram_pixbuf;
	PixelTransformer* transformer;
	PixelTransformer* histogram_transformer;
	PixelTransformationBundle* transformations;
	gfloat* fp_pixel_cache;
	gint fp_pixel_cache_length1;
	gint _fp_pixel_cache_size_;
	gboolean disable_histogram_refresh;
	OneShotScheduler* temperature_scheduler;
	OneShotScheduler* tint_scheduler;
	OneShotScheduler* contrast_scheduler;
	OneShotScheduler* saturation_scheduler;
	OneShotScheduler* exposure_scheduler;
	OneShotScheduler* shadows_scheduler;
	OneShotScheduler* highlights_scheduler;
};

struct _EditingToolsAdjustToolAdjustToolWindow {
	EditingToolsEditingToolWindow parent_instance;
	EditingToolsAdjustToolAdjustToolWindowPrivate * priv;
	GtkScale* exposure_slider;
	GtkScale* contrast_slider;
	GtkScale* saturation_slider;
	GtkScale* tint_slider;
	GtkScale* temperature_slider;
	GtkScale* shadows_slider;
	GtkScale* highlights_slider;
	GtkButton* ok_button;
	GtkButton* reset_button;
	GtkButton* cancel_button;
	RGBHistogramManipulator* histogram_manipulator;
};

struct _EditingToolsAdjustToolAdjustToolWindowClass {
	EditingToolsEditingToolWindowClass parent_class;
};

struct _CommandDescriptionIface {
	GTypeInterface parent_iface;
	gchar* (*get_name) (CommandDescription* self);
	gchar* (*get_explanation) (CommandDescription* self);
};

struct _Command {
	GObject parent_instance;
	CommandPrivate * priv;
};

struct _CommandClass {
	GObjectClass parent_class;
	void (*prepare) (Command* self);
	void (*execute) (Command* self);
	void (*undo) (Command* self);
	void (*redo) (Command* self);
	gboolean (*compress) (Command* self, Command* command);
	gchar* (*get_name) (Command* self);
	gchar* (*get_explanation) (Command* self);
};

struct _EditingToolsAdjustToolAdjustToolCommand {
	Command parent_instance;
	EditingToolsAdjustToolAdjustToolCommandPrivate * priv;
	EditingToolsAdjustTool* owner;
};

struct _EditingToolsAdjustToolAdjustToolCommandClass {
	CommandClass parent_class;
};

struct _EditingToolsAdjustToolAdjustResetCommand {
	EditingToolsAdjustToolAdjustToolCommand parent_instance;
	EditingToolsAdjustToolAdjustResetCommandPrivate * priv;
};

struct _EditingToolsAdjustToolAdjustResetCommandClass {
	EditingToolsAdjustToolAdjustToolCommandClass parent_class;
};

struct _EditingToolsAdjustToolAdjustResetCommandPrivate {
	PixelTransformationBundle* original;
	PixelTransformationBundle* reset;
};

struct _EditingToolsAdjustToolSliderAdjustmentCommand {
	EditingToolsAdjustToolAdjustToolCommand parent_instance;
	EditingToolsAdjustToolSliderAdjustmentCommandPrivate * priv;
};

struct _EditingToolsAdjustToolSliderAdjustmentCommandClass {
	EditingToolsAdjustToolAdjustToolCommandClass parent_class;
};

struct _EditingToolsAdjustToolSliderAdjustmentCommandPrivate {
	PixelTransformationType transformation_type;
	PixelTransformation* new_transformation;
	PixelTransformation* old_transformation;
};

struct _EditingToolsAdjustToolAdjustEnhanceCommand {
	EditingToolsAdjustToolAdjustToolCommand parent_instance;
	EditingToolsAdjustToolAdjustEnhanceCommandPrivate * priv;
};

struct _EditingToolsAdjustToolAdjustEnhanceCommandClass {
	EditingToolsAdjustToolAdjustToolCommandClass parent_class;
};

struct _EditingToolsAdjustToolAdjustEnhanceCommandPrivate {
	Photo* photo;
	PixelTransformationBundle* original;
	PixelTransformationBundle* enhanced;
};

static gint EditingToolsEditingToolWindow_private_offset;
static gpointer editing_tools_editing_tool_window_parent_class = NULL;
static gint EditingToolsPhotoCanvas_private_offset;
static gpointer editing_tools_photo_canvas_parent_class = NULL;
static gint EditingToolsEditingTool_private_offset;
static gpointer editing_tools_editing_tool_parent_class = NULL;
static gint EditingToolsCropTool_private_offset;
static gpointer editing_tools_crop_tool_parent_class = NULL;
static gpointer editing_tools_crop_tool_constraint_description_parent_class = NULL;
static gpointer editing_tools_crop_tool_crop_tool_window_parent_class = NULL;
static gint EditingToolsRedeyeTool_private_offset;
static gpointer editing_tools_redeye_tool_parent_class = NULL;
static gint EditingToolsRedeyeToolRedeyeToolWindow_private_offset;
static gpointer editing_tools_redeye_tool_redeye_tool_window_parent_class = NULL;
static gint EditingToolsAdjustTool_private_offset;
static gpointer editing_tools_adjust_tool_parent_class = NULL;
static gpointer editing_tools_adjust_tool_adjust_tool_window_parent_class = NULL;
static gpointer editing_tools_adjust_tool_adjust_tool_command_parent_class = NULL;
static gint EditingToolsAdjustToolAdjustResetCommand_private_offset;
static gpointer editing_tools_adjust_tool_adjust_reset_command_parent_class = NULL;
static gint EditingToolsAdjustToolSliderAdjustmentCommand_private_offset;
static gpointer editing_tools_adjust_tool_slider_adjustment_command_parent_class = NULL;
static gint EditingToolsAdjustToolAdjustEnhanceCommand_private_offset;
static gpointer editing_tools_adjust_tool_adjust_enhance_command_parent_class = NULL;

VALA_EXTERN void editing_tools_preconfigure (void);
VALA_EXTERN void editing_tools_init (GError** error);
VALA_EXTERN void editing_tools_terminate (void);
VALA_EXTERN GType editing_tools_editing_tool_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsEditingToolWindow, g_object_unref)
VALA_EXTERN EditingToolsEditingToolWindow* editing_tools_editing_tool_window_construct (GType object_type,
                                                                            GtkWindow* container);
static void editing_tools_editing_tool_window_suppress_warnings (EditingToolsEditingToolWindow* self,
                                                          const gchar* log_domain,
                                                          GLogLevelFlags log_levels,
                                                          const gchar* message);
static void _editing_tools_editing_tool_window_suppress_warnings_glog_func (const gchar* log_domain,
                                                                     GLogLevelFlags log_levels,
                                                                     const gchar* message,
                                                                     gpointer self);
static void editing_tools_editing_tool_window_real_add (GtkContainer* base,
                                                 GtkWidget* widget);
VALA_EXTERN gboolean editing_tools_editing_tool_window_has_user_moved (EditingToolsEditingToolWindow* self);
static gboolean editing_tools_editing_tool_window_real_key_press_event (GtkWidget* base,
                                                                 GdkEventKey* event);
VALA_EXTERN GType page_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PageWindow, g_object_unref)
VALA_EXTERN GType app_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AppWindow, g_object_unref)
VALA_EXTERN AppWindow* app_window_get_instance (void);
static gboolean editing_tools_editing_tool_window_real_button_press_event (GtkWidget* base,
                                                                    GdkEventButton* event);
static void editing_tools_editing_tool_window_real_realize (GtkWidget* base);
static void editing_tools_editing_tool_window_finalize (GObject * obj);
static GType editing_tools_editing_tool_window_get_type_once (void);
VALA_EXTERN gpointer editing_tools_photo_canvas_ref (gpointer instance);
VALA_EXTERN void editing_tools_photo_canvas_unref (gpointer instance);
VALA_EXTERN GParamSpec* editing_tools_param_spec_photo_canvas (const gchar* name,
                                                   const gchar* nick,
                                                   const gchar* blurb,
                                                   GType object_type,
                                                   GParamFlags flags);
VALA_EXTERN void editing_tools_value_set_photo_canvas (GValue* value,
                                           gpointer v_object);
VALA_EXTERN void editing_tools_value_take_photo_canvas (GValue* value,
                                            gpointer v_object);
VALA_EXTERN gpointer editing_tools_value_get_photo_canvas (const GValue* value);
VALA_EXTERN GType editing_tools_photo_canvas_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsPhotoCanvas, editing_tools_photo_canvas_unref)
VALA_EXTERN GType data_object_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DataObject, g_object_unref)
VALA_EXTERN GType data_source_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DataSource, g_object_unref)
VALA_EXTERN GType thumbnail_source_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ThumbnailSource, g_object_unref)
VALA_EXTERN GType media_source_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MediaSource, g_object_unref)
VALA_EXTERN GType photo_source_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoSource, g_object_unref)
VALA_EXTERN GType photo_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Photo, g_object_unref)
VALA_EXTERN GType dimensions_get_type (void) G_GNUC_CONST ;
VALA_EXTERN Dimensions* dimensions_dup (const Dimensions* self);
VALA_EXTERN void dimensions_free (Dimensions* self);
VALA_EXTERN void editing_tools_photo_canvas_repaint (EditingToolsPhotoCanvas* self);
VALA_EXTERN EditingToolsPhotoCanvas* editing_tools_photo_canvas_construct (GType object_type,
                                                               GtkWindow* container,
                                                               GdkWindow* drawing_window,
                                                               Photo* photo,
                                                               cairo_t* default_ctx,
                                                               Dimensions* surface_dim,
                                                               GdkPixbuf* scaled,
                                                               GdkRectangle* scaled_position);
static cairo_surface_t* editing_tools_photo_canvas_pixbuf_to_surface (EditingToolsPhotoCanvas* self,
                                                               cairo_t* default_ctx,
                                                               GdkPixbuf* pixbuf,
                                                               GdkRectangle* pos);
VALA_EXTERN void editing_tools_photo_canvas_unscaled_to_raw_rect (EditingToolsPhotoCanvas* self,
                                                      GdkRectangle* rectangle,
                                                      GdkRectangle* result);
VALA_EXTERN void photo_unscaled_to_raw_rect (Photo* self,
                                 GdkRectangle* unscaled_rect,
                                 GdkRectangle* result);
VALA_EXTERN void editing_tools_photo_canvas_active_to_unscaled_point (EditingToolsPhotoCanvas* self,
                                                          GdkPoint* active_point,
                                                          GdkPoint* result);
VALA_EXTERN void editing_tools_photo_canvas_get_scaled_pixbuf_position (EditingToolsPhotoCanvas* self,
                                                            GdkRectangle* result);
VALA_EXTERN GType photo_exception_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void media_source_get_dimensions (MediaSource* self,
                                  PhotoException disallowed_steps,
                                  Dimensions* result);
VALA_EXTERN void editing_tools_photo_canvas_active_to_unscaled_rect (EditingToolsPhotoCanvas* self,
                                                         GdkRectangle* active_rect,
                                                         GdkRectangle* result);
VALA_EXTERN void editing_tools_photo_canvas_user_to_active_point (EditingToolsPhotoCanvas* self,
                                                      GdkPoint* user_point,
                                                      GdkPoint* result);
VALA_EXTERN void editing_tools_photo_canvas_user_to_active_rect (EditingToolsPhotoCanvas* self,
                                                     GdkRectangle* user_rect,
                                                     GdkRectangle* result);
VALA_EXTERN Photo* editing_tools_photo_canvas_get_photo (EditingToolsPhotoCanvas* self);
VALA_EXTERN GtkWindow* editing_tools_photo_canvas_get_container (EditingToolsPhotoCanvas* self);
VALA_EXTERN GdkWindow* editing_tools_photo_canvas_get_drawing_window (EditingToolsPhotoCanvas* self);
VALA_EXTERN cairo_t* editing_tools_photo_canvas_get_default_ctx (EditingToolsPhotoCanvas* self);
VALA_EXTERN void editing_tools_photo_canvas_get_surface_dim (EditingToolsPhotoCanvas* self,
                                                 Dimensions* result);
VALA_EXTERN GType scaling_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType scale_constraint_get_type (void) G_GNUC_CONST ;
VALA_EXTERN Scaling* scaling_dup (const Scaling* self);
VALA_EXTERN void scaling_free (Scaling* self);
VALA_EXTERN void editing_tools_photo_canvas_get_scaling (EditingToolsPhotoCanvas* self,
                                             Scaling* result);
VALA_EXTERN void scaling_for_viewport (Dimensions* viewport,
                           gboolean scale_up,
                           Scaling* result);
VALA_EXTERN void editing_tools_photo_canvas_set_surface (EditingToolsPhotoCanvas* self,
                                             cairo_t* default_ctx,
                                             Dimensions* surface_dim);
VALA_EXTERN cairo_surface_t* editing_tools_photo_canvas_get_scaled_surface (EditingToolsPhotoCanvas* self);
VALA_EXTERN GdkPixbuf* editing_tools_photo_canvas_get_scaled_pixbuf (EditingToolsPhotoCanvas* self);
VALA_EXTERN void editing_tools_photo_canvas_resized_pixbuf (EditingToolsPhotoCanvas* self,
                                                Dimensions* old_dim,
                                                GdkPixbuf* scaled,
                                                GdkRectangle* scaled_position);
static void editing_tools_photo_canvas_real_repaint (EditingToolsPhotoCanvas* self);
VALA_EXTERN void editing_tools_photo_canvas_paint_pixbuf (EditingToolsPhotoCanvas* self,
                                              GdkPixbuf* pixbuf);
VALA_EXTERN void set_source_color_from_string (cairo_t* ctx,
                                   const gchar* spec);
VALA_EXTERN void paint_pixmap_with_background (cairo_t* ctx,
                                   GdkPixbuf* pixbuf,
                                   gint x,
                                   gint y);
VALA_EXTERN void editing_tools_photo_canvas_paint_surface (EditingToolsPhotoCanvas* self,
                                               cairo_surface_t* surface,
                                               gboolean over);
VALA_EXTERN GType box_get_type (void) G_GNUC_CONST ;
VALA_EXTERN Box* box_dup (const Box* self);
VALA_EXTERN void box_free (Box* self);
VALA_EXTERN void editing_tools_photo_canvas_paint_surface_area (EditingToolsPhotoCanvas* self,
                                                    cairo_surface_t* surface,
                                                    Box* source_area,
                                                    gboolean over);
VALA_EXTERN gint box_get_width (Box *self);
VALA_EXTERN gint box_get_height (Box *self);
VALA_EXTERN void editing_tools_photo_canvas_draw_box (EditingToolsPhotoCanvas* self,
                                          cairo_t* ctx,
                                          Box* box);
VALA_EXTERN void box_get_rectangle (Box *self,
                        GdkRectangle* result);
VALA_EXTERN void editing_tools_photo_canvas_draw_text (EditingToolsPhotoCanvas* self,
                                           cairo_t* ctx,
                                           const gchar* text,
                                           gint x,
                                           gint y,
                                           gboolean use_scaled_pos);
VALA_EXTERN void editing_tools_photo_canvas_draw_horizontal_line (EditingToolsPhotoCanvas* self,
                                                      cairo_t* ctx,
                                                      gint x,
                                                      gint y,
                                                      gint width,
                                                      gboolean use_scaled_pos);
VALA_EXTERN void editing_tools_photo_canvas_draw_vertical_line (EditingToolsPhotoCanvas* self,
                                                    cairo_t* ctx,
                                                    gint x,
                                                    gint y,
                                                    gint height,
                                                    gboolean use_scaled_pos);
VALA_EXTERN void editing_tools_photo_canvas_erase_horizontal_line (EditingToolsPhotoCanvas* self,
                                                       gint x,
                                                       gint y,
                                                       gint width);
VALA_EXTERN gdouble application_get_scale (void);
VALA_EXTERN void editing_tools_photo_canvas_draw_circle (EditingToolsPhotoCanvas* self,
                                             cairo_t* ctx,
                                             gint active_center_x,
                                             gint active_center_y,
                                             gint radius);
VALA_EXTERN void editing_tools_photo_canvas_erase_vertical_line (EditingToolsPhotoCanvas* self,
                                                     gint x,
                                                     gint y,
                                                     gint height);
VALA_EXTERN void editing_tools_photo_canvas_erase_box (EditingToolsPhotoCanvas* self,
                                           Box* box);
VALA_EXTERN void editing_tools_photo_canvas_invalidate_area (EditingToolsPhotoCanvas* self,
                                                 Box* area);
VALA_EXTERN void editing_tools_photo_canvas_set_cursor (EditingToolsPhotoCanvas* self,
                                            GdkCursorType cursor_type);
static void g_cclosure_user_marshal_VOID__BOXED_BOXED (GClosure * closure,
                                                GValue * return_value,
                                                guint n_param_values,
                                                const GValue * param_values,
                                                gpointer invocation_hint,
                                                gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__BOXED_OBJECT_BOXED (GClosure * closure,
                                                       GValue * return_value,
                                                       guint n_param_values,
                                                       const GValue * param_values,
                                                       gpointer invocation_hint,
                                                       gpointer marshal_data);
static void editing_tools_photo_canvas_finalize (EditingToolsPhotoCanvas * obj);
static GType editing_tools_photo_canvas_get_type_once (void);
VALA_EXTERN gpointer editing_tools_editing_tool_ref (gpointer instance);
VALA_EXTERN void editing_tools_editing_tool_unref (gpointer instance);
VALA_EXTERN GParamSpec* editing_tools_param_spec_editing_tool (const gchar* name,
                                                   const gchar* nick,
                                                   const gchar* blurb,
                                                   GType object_type,
                                                   GParamFlags flags);
VALA_EXTERN void editing_tools_value_set_editing_tool (GValue* value,
                                           gpointer v_object);
VALA_EXTERN void editing_tools_value_take_editing_tool (GValue* value,
                                            gpointer v_object);
VALA_EXTERN gpointer editing_tools_value_get_editing_tool (const GValue* value);
VALA_EXTERN GType editing_tools_editing_tool_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsEditingTool, editing_tools_editing_tool_unref)
VALA_EXTERN void editing_tools_editing_tool_activate (EditingToolsEditingTool* self,
                                          EditingToolsPhotoCanvas* canvas);
VALA_EXTERN void editing_tools_editing_tool_deactivate (EditingToolsEditingTool* self);
VALA_EXTERN EditingToolsEditingToolWindow* editing_tools_editing_tool_get_tool_window (EditingToolsEditingTool* self);
VALA_EXTERN GdkPixbuf* editing_tools_editing_tool_get_display_pixbuf (EditingToolsEditingTool* self,
                                                          Scaling* scaling,
                                                          Photo* photo,
                                                          Dimensions* max_dim,
                                                          GError** error);
VALA_EXTERN void editing_tools_editing_tool_on_left_click (EditingToolsEditingTool* self,
                                               gint x,
                                               gint y);
VALA_EXTERN void editing_tools_editing_tool_on_left_released (EditingToolsEditingTool* self,
                                                  gint x,
                                                  gint y);
VALA_EXTERN void editing_tools_editing_tool_on_motion (EditingToolsEditingTool* self,
                                           gint x,
                                           gint y,
                                           GdkModifierType mask);
VALA_EXTERN gboolean editing_tools_editing_tool_on_leave_notify_event (EditingToolsEditingTool* self);
VALA_EXTERN gboolean editing_tools_editing_tool_on_keypress (EditingToolsEditingTool* self,
                                                 GdkEventKey* event);
VALA_EXTERN void editing_tools_editing_tool_paint (EditingToolsEditingTool* self,
                                       cairo_t* ctx);
VALA_EXTERN EditingToolsEditingTool* editing_tools_editing_tool_construct (GType object_type,
                                                               const gchar* name);
static void editing_tools_editing_tool_real_activate (EditingToolsEditingTool* self,
                                               EditingToolsPhotoCanvas* canvas);
static gboolean _editing_tools_editing_tool_on_keypress_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                             GdkEventKey* event,
                                                                             gpointer self);
static void editing_tools_editing_tool_real_deactivate (EditingToolsEditingTool* self);
VALA_EXTERN gboolean editing_tools_editing_tool_is_activated (EditingToolsEditingTool* self);
static EditingToolsEditingToolWindow* editing_tools_editing_tool_real_get_tool_window (EditingToolsEditingTool* self);
static GdkPixbuf* editing_tools_editing_tool_real_get_display_pixbuf (EditingToolsEditingTool* self,
                                                               Scaling* scaling,
                                                               Photo* photo,
                                                               Dimensions* max_dim,
                                                               GError** error);
VALA_EXTERN void dimensions_init (Dimensions *self,
                      gint width,
                      gint height);
static void editing_tools_editing_tool_real_on_left_click (EditingToolsEditingTool* self,
                                                    gint x,
                                                    gint y);
static void editing_tools_editing_tool_real_on_left_released (EditingToolsEditingTool* self,
                                                       gint x,
                                                       gint y);
static void editing_tools_editing_tool_real_on_motion (EditingToolsEditingTool* self,
                                                gint x,
                                                gint y,
                                                GdkModifierType mask);
static gboolean editing_tools_editing_tool_real_on_leave_notify_event (EditingToolsEditingTool* self);
static gboolean editing_tools_editing_tool_real_on_keypress (EditingToolsEditingTool* self,
                                                      GdkEventKey* event);
VALA_EXTERN void editing_tools_editing_tool_notify_cancel (EditingToolsEditingTool* self);
static void editing_tools_editing_tool_real_paint (EditingToolsEditingTool* self,
                                            cairo_t* ctx);
VALA_EXTERN GType command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Command, g_object_unref)
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT_BOXED_BOOLEAN (GClosure * closure,
                                                                GValue * return_value,
                                                                guint n_param_values,
                                                                const GValue * param_values,
                                                                gpointer invocation_hint,
                                                                gpointer marshal_data);
static void editing_tools_editing_tool_finalize (EditingToolsEditingTool * obj);
static GType editing_tools_editing_tool_get_type_once (void);
VALA_EXTERN GType editing_tools_crop_tool_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsCropTool, editing_tools_editing_tool_unref)
static GType editing_tools_crop_tool_crop_tool_window_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsCropToolCropToolWindow, g_object_unref)
VALA_EXTERN GType box_location_get_type (void) G_GNUC_CONST ;
static gpointer editing_tools_crop_tool_constraint_description_ref (gpointer instance);
static void editing_tools_crop_tool_constraint_description_unref (gpointer instance);
static GParamSpec* editing_tools_crop_tool_param_spec_constraint_description (const gchar* name,
                                                                       const gchar* nick,
                                                                       const gchar* blurb,
                                                                       GType object_type,
                                                                       GParamFlags flags) G_GNUC_UNUSED ;
static void editing_tools_crop_tool_value_set_constraint_description (GValue* value,
                                                               gpointer v_object) G_GNUC_UNUSED ;
static void editing_tools_crop_tool_value_take_constraint_description (GValue* value,
                                                                gpointer v_object) G_GNUC_UNUSED ;
static gpointer editing_tools_crop_tool_value_get_constraint_description (const GValue* value) G_GNUC_UNUSED ;
static GType editing_tools_crop_tool_constraint_description_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsCropToolConstraintDescription, editing_tools_crop_tool_constraint_description_unref)
static GType editing_tools_crop_tool_reticle_orientation_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static GType editing_tools_crop_tool_constraint_mode_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static EditingToolsCropToolReticleOrientation editing_tools_crop_tool_reticle_orientation_toggle (EditingToolsCropToolReticleOrientation self);
static EditingToolsCropToolConstraintDescription** editing_tools_crop_tool_create_constraints (gint* result_length1);
static GtkListStore* editing_tools_crop_tool_create_constraint_list (EditingToolsCropToolConstraintDescription** constraint_data,
                                                              gint constraint_data_length1);
static EditingToolsCropTool* editing_tools_crop_tool_new (void);
static EditingToolsCropTool* editing_tools_crop_tool_construct (GType object_type);
VALA_EXTERN EditingToolsCropTool* editing_tools_crop_tool_factory (void);
VALA_EXTERN gboolean editing_tools_crop_tool_is_available (Photo* photo,
                                               Scaling* scaling);
VALA_EXTERN void scaling_get_scaled_dimensions (Scaling *self,
                                    Dimensions* original,
                                    Dimensions* result);
VALA_EXTERN void photo_get_original_dimensions (Photo* self,
                                    Dimensions* result);
static EditingToolsCropToolConstraintDescription* editing_tools_crop_tool_constraint_description_new (const gchar* new_name,
                                                                                               gint new_basis_width,
                                                                                               gint new_basis_height,
                                                                                               gboolean new_pivotable,
                                                                                               gfloat new_aspect_ratio);
static EditingToolsCropToolConstraintDescription* editing_tools_crop_tool_constraint_description_construct (GType object_type,
                                                                                                     const gchar* new_name,
                                                                                                     gint new_basis_width,
                                                                                                     gint new_basis_height,
                                                                                                     gboolean new_pivotable,
                                                                                                     gfloat new_aspect_ratio);
static void _vala_array_add5 (EditingToolsCropToolConstraintDescription** * array,
                       gint* length,
                       gint* size,
                       EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add6 (EditingToolsCropToolConstraintDescription** * array,
                       gint* length,
                       gint* size,
                       EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add7 (EditingToolsCropToolConstraintDescription** * array,
                       gint* length,
                       gint* size,
                       EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add8 (EditingToolsCropToolConstraintDescription** * array,
                       gint* length,
                       gint* size,
                       EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add9 (EditingToolsCropToolConstraintDescription** * array,
                       gint* length,
                       gint* size,
                       EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add10 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add11 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add12 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add13 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add14 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add15 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add16 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add17 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add18 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add19 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add20 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add21 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add22 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add23 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add24 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add25 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add26 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add27 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add28 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add29 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add30 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add31 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add32 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void _vala_array_add33 (EditingToolsCropToolConstraintDescription** * array,
                        gint* length,
                        gint* size,
                        EditingToolsCropToolConstraintDescription* value);
static void editing_tools_crop_tool_update_pivot_button_state (EditingToolsCropTool* self);
static EditingToolsCropToolConstraintDescription* editing_tools_crop_tool_get_selected_constraint (EditingToolsCropTool* self);
VALA_EXTERN void scaling_get_screen_dimensions (GtkWindow* window,
                                    Dimensions* result);
static gboolean editing_tools_crop_tool_on_width_entry_focus_out (EditingToolsCropTool* self,
                                                           GdkEventFocus* event);
static gboolean editing_tools_crop_tool_on_custom_entry_focus_out (EditingToolsCropTool* self,
                                                            GdkEventFocus* event);
static gboolean editing_tools_crop_tool_on_height_entry_focus_out (EditingToolsCropTool* self,
                                                            GdkEventFocus* event);
static void editing_tools_crop_tool_constrain_crop (EditingToolsCropTool* self,
                                             Box* crop,
                                             Box* result);
static void editing_tools_crop_tool_crop_resized (EditingToolsCropTool* self,
                                           Box* new_crop);
static void editing_tools_crop_tool_on_width_insert_text (EditingToolsCropTool* self,
                                                   const gchar* text,
                                                   gint length,
                                                   gint* position);
static void editing_tools_crop_tool_on_entry_insert_text (EditingToolsCropTool* self,
                                                   GtkEntry* sender,
                                                   const gchar* text,
                                                   gint length,
                                                   gint* position);
static void editing_tools_crop_tool_on_height_insert_text (EditingToolsCropTool* self,
                                                    const gchar* text,
                                                    gint length,
                                                    gint* position);
static gfloat editing_tools_crop_tool_get_constraint_aspect_ratio (EditingToolsCropTool* self);
static gfloat editing_tools_crop_tool_get_constraint_aspect_ratio_for_constraint (EditingToolsCropTool* self,
                                                                           EditingToolsCropToolConstraintDescription* constraint,
                                                                           Photo* photo);
static void editing_tools_crop_tool_constraint_changed (EditingToolsCropTool* self);
static void editing_tools_crop_tool_set_custom_constraint_mode (EditingToolsCropTool* self);
static void editing_tools_crop_tool_set_normal_constraint_mode (EditingToolsCropTool* self);
VALA_EXTERN GType configuration_facade_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigurationFacade, g_object_unref)
VALA_EXTERN GType config_facade_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigFacade, g_object_unref)
VALA_EXTERN ConfigFacade* config_facade_get_instance (void);
VALA_EXTERN gint configuration_facade_get_last_crop_width (ConfigurationFacade* self);
VALA_EXTERN gint configuration_facade_get_last_crop_height (ConfigurationFacade* self);
VALA_EXTERN void box_adjust_height (Box *self,
                        gint height);
VALA_EXTERN void box_adjust_width (Box *self,
                       gint width);
static void editing_tools_crop_tool_get_photo_dimensions (EditingToolsCropTool* self,
                                                   Dimensions* result);
VALA_EXTERN gboolean photo_get_straighten (Photo* self,
                               gdouble* theta);
VALA_EXTERN void clamp_inside_rotated_image (Box* src,
                                 gint img_w,
                                 gint img_h,
                                 gdouble angle_deg,
                                 gboolean preserve_geom,
                                 Box* result);
static EditingToolsCropToolConstraintDescription* editing_tools_crop_tool_get_last_constraint (EditingToolsCropTool* self,
                                                                                        gint* index);
VALA_EXTERN gint configuration_facade_get_last_crop_menu_choice (ConfigurationFacade* self);
static void editing_tools_crop_tool_real_activate (EditingToolsEditingTool* base,
                                            EditingToolsPhotoCanvas* canvas);
static void editing_tools_crop_tool_bind_canvas_handlers (EditingToolsCropTool* self,
                                                   EditingToolsPhotoCanvas* canvas);
static void editing_tools_crop_tool_prepare_ctx (EditingToolsCropTool* self,
                                          cairo_t* ctx,
                                          Dimensions* dim);
static EditingToolsCropToolCropToolWindow* editing_tools_crop_tool_crop_tool_window_new (GtkWindow* container);
static EditingToolsCropToolCropToolWindow* editing_tools_crop_tool_crop_tool_window_construct (GType object_type,
                                                                                        GtkWindow* container);
VALA_EXTERN gboolean photo_has_crop (Photo* self);
static gboolean editing_tools_crop_tool_constraint_description_is_separator (EditingToolsCropToolConstraintDescription* self);
static void editing_tools_crop_tool_bind_window_handlers (EditingToolsCropTool* self);
VALA_EXTERN gboolean photo_get_crop (Photo* self,
                         Box* crop,
                         PhotoException exceptions);
VALA_EXTERN void box_init (Box *self,
               gint left,
               gint top,
               gint right,
               gint bottom);
VALA_EXTERN void box_get_scaled_similar (Box *self,
                             Dimensions* original,
                             Dimensions* scaled,
                             Box* result);
VALA_EXTERN void dimensions_for_rectangle (GdkRectangle* rect,
                               Dimensions* result);
static void _editing_tools_crop_tool_prepare_ctx_editing_tools_photo_canvas_new_surface (EditingToolsPhotoCanvas* _sender,
                                                                                  cairo_t* ctx,
                                                                                  Dimensions* dim,
                                                                                  gpointer self);
static void editing_tools_crop_tool_on_resized_pixbuf (EditingToolsCropTool* self,
                                                Dimensions* old_dim,
                                                GdkPixbuf* scaled,
                                                GdkRectangle* scaled_position);
static void _editing_tools_crop_tool_on_resized_pixbuf_editing_tools_photo_canvas_resized_scaled_pixbuf (EditingToolsPhotoCanvas* _sender,
                                                                                                  Dimensions* old_dim,
                                                                                                  GdkPixbuf* scaled,
                                                                                                  GdkRectangle* scaled_position,
                                                                                                  gpointer self);
static void editing_tools_crop_tool_unbind_canvas_handlers (EditingToolsCropTool* self,
                                                     EditingToolsPhotoCanvas* canvas);
static void editing_tools_crop_tool_on_crop_ok (EditingToolsCropTool* self);
static void _editing_tools_crop_tool_on_crop_ok_gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self);
static void _editing_tools_editing_tool_notify_cancel_gtk_button_clicked (GtkButton* _sender,
                                                                   gpointer self);
static void _editing_tools_crop_tool_constraint_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                        gpointer self);
static void editing_tools_crop_tool_on_pivot_button_clicked (EditingToolsCropTool* self);
static void _editing_tools_crop_tool_on_pivot_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                          gpointer self);
static gboolean _editing_tools_crop_tool_on_width_entry_focus_out_gtk_widget_focus_out_event (GtkWidget* _sender,
                                                                                       GdkEventFocus* event,
                                                                                       gpointer self);
static gboolean _editing_tools_crop_tool_on_height_entry_focus_out_gtk_widget_focus_out_event (GtkWidget* _sender,
                                                                                        GdkEventFocus* event,
                                                                                        gpointer self);
static void _editing_tools_crop_tool_on_width_insert_text_gtk_editable_insert_text (GtkEditable* _sender,
                                                                             const gchar* new_text,
                                                                             gint new_text_length,
                                                                             gint* position,
                                                                             gpointer self);
static void _editing_tools_crop_tool_on_height_insert_text_gtk_editable_insert_text (GtkEditable* _sender,
                                                                              const gchar* new_text,
                                                                              gint new_text_length,
                                                                              gint* position,
                                                                              gpointer self);
static void editing_tools_crop_tool_unbind_window_handlers (EditingToolsCropTool* self);
static gboolean editing_tools_crop_tool_real_on_keypress (EditingToolsEditingTool* base,
                                                   GdkEventKey* event);
static void editing_tools_crop_tool_real_deactivate (EditingToolsEditingTool* base);
static EditingToolsEditingToolWindow* editing_tools_crop_tool_real_get_tool_window (EditingToolsEditingTool* base);
static GdkPixbuf* editing_tools_crop_tool_real_get_display_pixbuf (EditingToolsEditingTool* base,
                                                            Scaling* scaling,
                                                            Photo* photo,
                                                            Dimensions* max_dim,
                                                            GError** error);
VALA_EXTERN GType backing_fetch_mode_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GdkPixbuf* photo_get_pixbuf_with_options (Photo* self,
                                          Scaling* scaling,
                                          PhotoException exceptions,
                                          BackingFetchMode fetch_mode,
                                          GError** error);
VALA_EXTERN void dimensions_for_pixbuf (GdkPixbuf* pixbuf,
                            Dimensions* result);
static void editing_tools_crop_tool_real_on_left_click (EditingToolsEditingTool* base,
                                                 gint x,
                                                 gint y);
VALA_EXTERN void box_get_offset (Box *self,
                     gint xofs,
                     gint yofs,
                     Box* result);
VALA_EXTERN BoxLocation box_approx_location (Box *self,
                                 gint x,
                                 gint y);
static void editing_tools_crop_tool_real_on_left_released (EditingToolsEditingTool* base,
                                                    gint x,
                                                    gint y);
static void editing_tools_crop_tool_update_cursor (EditingToolsCropTool* self,
                                            gint x,
                                            gint y);
static void editing_tools_crop_tool_real_on_motion (EditingToolsEditingTool* base,
                                             gint x,
                                             gint y,
                                             GdkModifierType mask);
static gboolean editing_tools_crop_tool_on_canvas_manipulation (EditingToolsCropTool* self,
                                                         gint x,
                                                         gint y);
static void editing_tools_crop_tool_real_paint (EditingToolsEditingTool* base,
                                         cairo_t* default_ctx);
static void editing_tools_crop_tool_paint_crop_tool (EditingToolsCropTool* self,
                                              Box* crop);
VALA_EXTERN void configuration_facade_set_last_crop_menu_choice (ConfigurationFacade* self,
                                                     gint choice);
VALA_EXTERN void configuration_facade_set_last_crop_width (ConfigurationFacade* self,
                                               gint choice);
VALA_EXTERN void configuration_facade_set_last_crop_height (ConfigurationFacade* self,
                                                gint choice);
VALA_EXTERN CropCommand* crop_command_new (Photo* photo,
                               Box* crop,
                               const gchar* name,
                               const gchar* explanation);
VALA_EXTERN CropCommand* crop_command_construct (GType object_type,
                                     Photo* photo,
                                     Box* crop,
                                     const gchar* name,
                                     const gchar* explanation);
VALA_EXTERN GType page_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PageCommand, g_object_unref)
VALA_EXTERN GType single_data_source_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SingleDataSourceCommand, g_object_unref)
VALA_EXTERN GType generic_photo_transformation_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GenericPhotoTransformationCommand, g_object_unref)
VALA_EXTERN GType crop_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CropCommand, g_object_unref)
VALA_EXTERN void box_get_dimensions (Box *self,
                         Dimensions* result);
static gint editing_tools_crop_tool_eval_radial_line (EditingToolsCropTool* self,
                                               gdouble center_x,
                                               gdouble center_y,
                                               gdouble bounds_x,
                                               gdouble bounds_y,
                                               gdouble user_x);
static gboolean _box_equal (const Box * s1,
                     const Box * s2);
static void editing_tools_crop_tool_crop_moved (EditingToolsCropTool* self,
                                         Box* new_crop);
VALA_EXTERN gboolean box_equals (Box *self,
                     Box* box);
VALA_EXTERN GType box_complements_get_type (void) G_GNUC_CONST ;
VALA_EXTERN BoxComplements box_resized_complements (Box *self,
                                        Box* resized,
                                        Box* horizontal,
                                        gboolean* horizontal_enlarged,
                                        Box* vertical,
                                        gboolean* vertical_enlarged);
static void editing_tools_crop_tool_set_area_alpha (EditingToolsCropTool* self,
                                             Box* area,
                                             gdouble alpha);
VALA_EXTERN void box_get_reduced (Box *self,
                      gint amount,
                      Box* result);
static void editing_tools_crop_tool_constraint_description_finalize (EditingToolsCropToolConstraintDescription * obj);
static GType editing_tools_crop_tool_constraint_description_get_type_once (void);
static gboolean editing_tools_crop_tool_crop_tool_window_constraint_combo_separator_func (GtkTreeModel* model,
                                                                                   GtkTreeIter* iter);
static gboolean _editing_tools_crop_tool_crop_tool_window_constraint_combo_separator_func_gtk_tree_view_row_separator_func (GtkTreeModel* model,
                                                                                                                     GtkTreeIter* iter,
                                                                                                                     gpointer self);
static void editing_tools_crop_tool_crop_tool_window_finalize (GObject * obj);
static GType editing_tools_crop_tool_crop_tool_window_get_type_once (void);
static void editing_tools_crop_tool_finalize (EditingToolsEditingTool * obj);
static GType editing_tools_crop_tool_get_type_once (void);
VALA_EXTERN GType editing_tools_redeye_instance_get_type (void) G_GNUC_CONST ;
VALA_EXTERN EditingToolsRedeyeInstance* editing_tools_redeye_instance_dup (const EditingToolsRedeyeInstance* self);
VALA_EXTERN void editing_tools_redeye_instance_free (EditingToolsRedeyeInstance* self);
static void editing_tools_redeye_instance_init (EditingToolsRedeyeInstance *self);
VALA_EXTERN void editing_tools_redeye_instance_to_bounds_rect (EditingToolsRedeyeInstance* inst,
                                                   GdkRectangle* result);
VALA_EXTERN void editing_tools_redeye_instance_from_bounds_rect (GdkRectangle* rect,
                                                     EditingToolsRedeyeInstance* result);
VALA_EXTERN GType editing_tools_redeye_tool_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsRedeyeTool, editing_tools_editing_tool_unref)
static GType editing_tools_redeye_tool_redeye_tool_window_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsRedeyeToolRedeyeToolWindow, g_object_unref)
static EditingToolsRedeyeTool* editing_tools_redeye_tool_new (void);
static EditingToolsRedeyeTool* editing_tools_redeye_tool_construct (GType object_type);
VALA_EXTERN EditingToolsRedeyeTool* editing_tools_redeye_tool_factory (void);
VALA_EXTERN gboolean editing_tools_redeye_tool_is_available (Photo* photo,
                                                 Scaling* scaling);
static void editing_tools_redeye_tool_new_interaction_instance (EditingToolsRedeyeTool* self,
                                                         EditingToolsPhotoCanvas* canvas,
                                                         EditingToolsRedeyeInstance* result);
static void editing_tools_redeye_tool_prepare_ctx (EditingToolsRedeyeTool* self,
                                            cairo_t* ctx,
                                            Dimensions* dim);
static void editing_tools_redeye_tool_draw_redeye_instance (EditingToolsRedeyeTool* self,
                                                     EditingToolsRedeyeInstance* inst);
static gboolean editing_tools_redeye_tool_on_size_slider_adjust (EditingToolsRedeyeTool* self,
                                                          GtkScrollType type);
static void editing_tools_redeye_tool_on_apply (EditingToolsRedeyeTool* self);
VALA_EXTERN void derotate_point_arb (GdkPoint* source_point,
                         gint img_w,
                         gint img_h,
                         gdouble angle,
                         GdkPoint* result);
VALA_EXTERN GType redeye_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RedeyeCommand, g_object_unref)
VALA_EXTERN RedeyeCommand* redeye_command_new (Photo* photo,
                                   EditingToolsRedeyeInstance* redeye_instance,
                                   const gchar* name,
                                   const gchar* explanation);
VALA_EXTERN RedeyeCommand* redeye_command_construct (GType object_type,
                                         Photo* photo,
                                         EditingToolsRedeyeInstance* redeye_instance,
                                         const gchar* name,
                                         const gchar* explanation);
VALA_EXTERN gpointer command_manager_ref (gpointer instance);
VALA_EXTERN void command_manager_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_command_manager (const gchar* name,
                                        const gchar* nick,
                                        const gchar* blurb,
                                        GType object_type,
                                        GParamFlags flags);
VALA_EXTERN void value_set_command_manager (GValue* value,
                                gpointer v_object);
VALA_EXTERN void value_take_command_manager (GValue* value,
                                 gpointer v_object);
VALA_EXTERN gpointer value_get_command_manager (const GValue* value);
VALA_EXTERN GType command_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CommandManager, command_manager_unref)
VALA_EXTERN CommandManager* app_window_get_command_manager (void);
VALA_EXTERN void command_manager_execute (CommandManager* self,
                              Command* command);
VALA_EXTERN gpointer alteration_ref (gpointer instance);
VALA_EXTERN void alteration_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_alteration (const gchar* name,
                                   const gchar* nick,
                                   const gchar* blurb,
                                   GType object_type,
                                   GParamFlags flags);
VALA_EXTERN void value_set_alteration (GValue* value,
                           gpointer v_object);
VALA_EXTERN void value_take_alteration (GValue* value,
                            gpointer v_object);
VALA_EXTERN gpointer value_get_alteration (const GValue* value);
VALA_EXTERN GType alteration_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Alteration, alteration_unref)
static void editing_tools_redeye_tool_on_photos_altered (EditingToolsRedeyeTool* self,
                                                  GeeMap* map);
VALA_EXTERN GdkPixbuf* photo_source_get_pixbuf (PhotoSource* self,
                                    Scaling* scaling,
                                    GError** error);
static void editing_tools_redeye_tool_on_close (EditingToolsRedeyeTool* self);
static void editing_tools_redeye_tool_on_canvas_resize (EditingToolsRedeyeTool* self);
static void editing_tools_redeye_tool_real_activate (EditingToolsEditingTool* base,
                                              EditingToolsPhotoCanvas* canvas);
static void editing_tools_redeye_tool_bind_canvas_handlers (EditingToolsRedeyeTool* self,
                                                     EditingToolsPhotoCanvas* canvas);
static EditingToolsRedeyeToolRedeyeToolWindow* editing_tools_redeye_tool_redeye_tool_window_new (GtkWindow* container);
static EditingToolsRedeyeToolRedeyeToolWindow* editing_tools_redeye_tool_redeye_tool_window_construct (GType object_type,
                                                                                                GtkWindow* container);
static void editing_tools_redeye_tool_bind_window_handlers (EditingToolsRedeyeTool* self);
VALA_EXTERN gpointer data_collection_ref (gpointer instance);
VALA_EXTERN void data_collection_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_data_collection (const gchar* name,
                                        const gchar* nick,
                                        const gchar* blurb,
                                        GType object_type,
                                        GParamFlags flags);
VALA_EXTERN void value_set_data_collection (GValue* value,
                                gpointer v_object);
VALA_EXTERN void value_take_data_collection (GValue* value,
                                 gpointer v_object);
VALA_EXTERN gpointer value_get_data_collection (const GValue* value);
VALA_EXTERN GType data_collection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DataCollection, data_collection_unref)
VALA_EXTERN DataCollection* data_object_get_membership (DataObject* self);
static void _editing_tools_redeye_tool_on_photos_altered_data_collection_items_altered (DataCollection* _sender,
                                                                                 GeeMap* items,
                                                                                 gpointer self);
static void editing_tools_redeye_tool_real_deactivate (EditingToolsEditingTool* base);
static void editing_tools_redeye_tool_unbind_canvas_handlers (EditingToolsRedeyeTool* self,
                                                       EditingToolsPhotoCanvas* canvas);
static void editing_tools_redeye_tool_unbind_window_handlers (EditingToolsRedeyeTool* self);
static void _editing_tools_redeye_tool_prepare_ctx_editing_tools_photo_canvas_new_surface (EditingToolsPhotoCanvas* _sender,
                                                                                    cairo_t* ctx,
                                                                                    Dimensions* dim,
                                                                                    gpointer self);
static void _editing_tools_redeye_tool_on_canvas_resize_editing_tools_photo_canvas_resized_scaled_pixbuf (EditingToolsPhotoCanvas* _sender,
                                                                                                   Dimensions* old_dim,
                                                                                                   GdkPixbuf* scaled,
                                                                                                   GdkRectangle* scaled_position,
                                                                                                   gpointer self);
static void _editing_tools_redeye_tool_on_apply_gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self);
static void _editing_tools_redeye_tool_on_close_gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self);
static gboolean _editing_tools_redeye_tool_on_size_slider_adjust_gtk_range_change_value (GtkRange* _sender,
                                                                                  GtkScrollType scroll,
                                                                                  gdouble new_value,
                                                                                  gpointer self);
static EditingToolsEditingToolWindow* editing_tools_redeye_tool_real_get_tool_window (EditingToolsEditingTool* base);
static void editing_tools_redeye_tool_real_paint (EditingToolsEditingTool* base,
                                           cairo_t* ctx);
static void editing_tools_redeye_tool_real_on_left_click (EditingToolsEditingTool* base,
                                                   gint x,
                                                   gint y);
VALA_EXTERN gboolean coord_in_rectangle (gint x,
                             gint y,
                             GdkRectangle* rect);
static void editing_tools_redeye_tool_real_on_left_released (EditingToolsEditingTool* base,
                                                      gint x,
                                                      gint y);
static void editing_tools_redeye_tool_real_on_motion (EditingToolsEditingTool* base,
                                               gint x,
                                               gint y,
                                               GdkModifierType mask);
static gboolean editing_tools_redeye_tool_real_on_keypress (EditingToolsEditingTool* base,
                                                     GdkEventKey* event);
static void editing_tools_redeye_tool_redeye_tool_window_finalize (GObject * obj);
static GType editing_tools_redeye_tool_redeye_tool_window_get_type_once (void);
static void editing_tools_redeye_tool_finalize (EditingToolsEditingTool * obj);
static GType editing_tools_redeye_tool_get_type_once (void);
VALA_EXTERN GType editing_tools_adjust_tool_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsAdjustTool, editing_tools_editing_tool_unref)
static GType editing_tools_adjust_tool_adjust_tool_window_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsAdjustToolAdjustToolWindow, g_object_unref)
VALA_EXTERN gpointer one_shot_scheduler_ref (gpointer instance);
VALA_EXTERN void one_shot_scheduler_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_one_shot_scheduler (const gchar* name,
                                           const gchar* nick,
                                           const gchar* blurb,
                                           GType object_type,
                                           GParamFlags flags);
VALA_EXTERN void value_set_one_shot_scheduler (GValue* value,
                                   gpointer v_object);
VALA_EXTERN void value_take_one_shot_scheduler (GValue* value,
                                    gpointer v_object);
VALA_EXTERN gpointer value_get_one_shot_scheduler (const GValue* value);
VALA_EXTERN GType one_shot_scheduler_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OneShotScheduler, one_shot_scheduler_unref)
static EditingToolsAdjustTool* editing_tools_adjust_tool_new (void);
static EditingToolsAdjustTool* editing_tools_adjust_tool_construct (GType object_type);
VALA_EXTERN EditingToolsAdjustTool* editing_tools_adjust_tool_factory (void);
VALA_EXTERN gboolean editing_tools_adjust_tool_is_available (Photo* photo,
                                                 Scaling* scaling);
static void editing_tools_adjust_tool_real_activate (EditingToolsEditingTool* base,
                                              EditingToolsPhotoCanvas* canvas);
static EditingToolsAdjustToolAdjustToolWindow* editing_tools_adjust_tool_adjust_tool_window_new (GtkWindow* container);
static EditingToolsAdjustToolAdjustToolWindow* editing_tools_adjust_tool_adjust_tool_window_construct (GType object_type,
                                                                                                GtkWindow* container);
VALA_EXTERN PixelTransformationBundle* photo_get_color_adjustments (Photo* self);
VALA_EXTERN GType rgb_histogram_manipulator_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RGBHistogramManipulator, g_object_unref)
VALA_EXTERN void rgb_histogram_manipulator_set_left_nub_position (RGBHistogramManipulator* self,
                                                      gint user_nub_pos);
VALA_EXTERN void rgb_histogram_manipulator_set_right_nub_position (RGBHistogramManipulator* self,
                                                       gint user_nub_pos);
static void editing_tools_adjust_tool_bind_canvas_handlers (EditingToolsAdjustTool* self,
                                                     EditingToolsPhotoCanvas* canvas);
static void editing_tools_adjust_tool_bind_window_handlers (EditingToolsAdjustTool* self);
static void editing_tools_adjust_tool_init_fp_pixel_cache (EditingToolsAdjustTool* self,
                                                    GdkPixbuf* source);
static void editing_tools_adjust_tool_on_photos_altered (EditingToolsAdjustTool* self,
                                                  GeeMap* map);
static void _editing_tools_adjust_tool_on_photos_altered_data_collection_items_altered (DataCollection* _sender,
                                                                                 GeeMap* items,
                                                                                 gpointer self);
static EditingToolsEditingToolWindow* editing_tools_adjust_tool_real_get_tool_window (EditingToolsEditingTool* base);
static void editing_tools_adjust_tool_real_deactivate (EditingToolsEditingTool* base);
static void editing_tools_adjust_tool_unbind_canvas_handlers (EditingToolsAdjustTool* self,
                                                       EditingToolsPhotoCanvas* canvas);
static void editing_tools_adjust_tool_unbind_window_handlers (EditingToolsAdjustTool* self);
static void editing_tools_adjust_tool_real_paint (EditingToolsEditingTool* base,
                                           cairo_t* ctx);
VALA_EXTERN void rgb_histogram_manipulator_update_histogram (RGBHistogramManipulator* self,
                                                 GdkPixbuf* source_pixbuf);
static GdkPixbuf* editing_tools_adjust_tool_real_get_display_pixbuf (EditingToolsEditingTool* base,
                                                              Scaling* scaling,
                                                              Photo* photo,
                                                              Dimensions* max_dim,
                                                              GError** error);
VALA_EXTERN gboolean photo_has_color_adjustments (Photo* self);
static void editing_tools_adjust_tool_on_reset (EditingToolsAdjustTool* self);
static GType editing_tools_adjust_tool_adjust_tool_command_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsAdjustToolAdjustToolCommand, g_object_unref)
static GType editing_tools_adjust_tool_adjust_reset_command_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsAdjustToolAdjustResetCommand, g_object_unref)
static EditingToolsAdjustToolAdjustResetCommand* editing_tools_adjust_tool_adjust_reset_command_new (EditingToolsAdjustTool* owner,
                                                                                              PixelTransformationBundle* current);
static EditingToolsAdjustToolAdjustResetCommand* editing_tools_adjust_tool_adjust_reset_command_construct (GType object_type,
                                                                                                    EditingToolsAdjustTool* owner,
                                                                                                    PixelTransformationBundle* current);
static void editing_tools_adjust_tool_on_ok (EditingToolsAdjustTool* self);
VALA_EXTERN AdjustColorsSingleCommand* adjust_colors_single_command_new (Photo* photo,
                                                             PixelTransformationBundle* transformations,
                                                             const gchar* name,
                                                             const gchar* explanation);
VALA_EXTERN AdjustColorsSingleCommand* adjust_colors_single_command_construct (GType object_type,
                                                                   Photo* photo,
                                                                   PixelTransformationBundle* transformations,
                                                                   const gchar* name,
                                                                   const gchar* explanation);
VALA_EXTERN GType adjust_colors_single_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AdjustColorsSingleCommand, g_object_unref)
static void editing_tools_adjust_tool_update_transformations (EditingToolsAdjustTool* self,
                                                       PixelTransformationBundle* new_transformations);
static void editing_tools_adjust_tool_update_transformation (EditingToolsAdjustTool* self,
                                                      PixelTransformation* new_transformation);
static void editing_tools_adjust_tool_slider_updated (EditingToolsAdjustTool* self,
                                               PixelTransformation* new_transformation,
                                               const gchar* name);
static GType editing_tools_adjust_tool_slider_adjustment_command_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsAdjustToolSliderAdjustmentCommand, g_object_unref)
static EditingToolsAdjustToolSliderAdjustmentCommand* editing_tools_adjust_tool_slider_adjustment_command_new (EditingToolsAdjustTool* owner,
                                                                                                        PixelTransformation* old_transformation,
                                                                                                        PixelTransformation* new_transformation,
                                                                                                        const gchar* name);
static EditingToolsAdjustToolSliderAdjustmentCommand* editing_tools_adjust_tool_slider_adjustment_command_construct (GType object_type,
                                                                                                              EditingToolsAdjustTool* owner,
                                                                                                              PixelTransformation* old_transformation,
                                                                                                              PixelTransformation* new_transformation,
                                                                                                              const gchar* name);
static void editing_tools_adjust_tool_on_temperature_adjustment (EditingToolsAdjustTool* self);
static void editing_tools_adjust_tool_on_delayed_temperature_adjustment (EditingToolsAdjustTool* self);
static void _editing_tools_adjust_tool_on_delayed_temperature_adjustment_one_shot_callback (gpointer self);
VALA_EXTERN OneShotScheduler* one_shot_scheduler_new (const gchar* name,
                                          OneShotCallback callback,
                                          gpointer callback_target);
VALA_EXTERN OneShotScheduler* one_shot_scheduler_construct (GType object_type,
                                                const gchar* name,
                                                OneShotCallback callback,
                                                gpointer callback_target);
VALA_EXTERN void one_shot_scheduler_after_timeout (OneShotScheduler* self,
                                       guint msec,
                                       gboolean reschedule);
static void editing_tools_adjust_tool_on_tint_adjustment (EditingToolsAdjustTool* self);
static void editing_tools_adjust_tool_on_delayed_tint_adjustment (EditingToolsAdjustTool* self);
static void _editing_tools_adjust_tool_on_delayed_tint_adjustment_one_shot_callback (gpointer self);
static void editing_tools_adjust_tool_on_contrast_adjustment (EditingToolsAdjustTool* self);
static void editing_tools_adjust_tool_on_delayed_contrast_adjustment (EditingToolsAdjustTool* self);
static void _editing_tools_adjust_tool_on_delayed_contrast_adjustment_one_shot_callback (gpointer self);
static void editing_tools_adjust_tool_on_saturation_adjustment (EditingToolsAdjustTool* self);
static void editing_tools_adjust_tool_on_delayed_saturation_adjustment (EditingToolsAdjustTool* self);
static void _editing_tools_adjust_tool_on_delayed_saturation_adjustment_one_shot_callback (gpointer self);
static void editing_tools_adjust_tool_on_exposure_adjustment (EditingToolsAdjustTool* self);
static void editing_tools_adjust_tool_on_delayed_exposure_adjustment (EditingToolsAdjustTool* self);
static void _editing_tools_adjust_tool_on_delayed_exposure_adjustment_one_shot_callback (gpointer self);
static void editing_tools_adjust_tool_on_shadows_adjustment (EditingToolsAdjustTool* self);
static void editing_tools_adjust_tool_on_delayed_shadows_adjustment (EditingToolsAdjustTool* self);
static void _editing_tools_adjust_tool_on_delayed_shadows_adjustment_one_shot_callback (gpointer self);
static void editing_tools_adjust_tool_on_highlights_adjustment (EditingToolsAdjustTool* self);
static void editing_tools_adjust_tool_on_delayed_highlights_adjustment (EditingToolsAdjustTool* self);
static void _editing_tools_adjust_tool_on_delayed_highlights_adjustment_one_shot_callback (gpointer self);
static void editing_tools_adjust_tool_on_histogram_constraint (EditingToolsAdjustTool* self);
VALA_EXTERN gint rgb_histogram_manipulator_get_left_nub_position (RGBHistogramManipulator* self);
VALA_EXTERN gint rgb_histogram_manipulator_get_right_nub_position (RGBHistogramManipulator* self);
static void editing_tools_adjust_tool_on_canvas_resize (EditingToolsAdjustTool* self);
static gboolean editing_tools_adjust_tool_on_hscale_reset (EditingToolsAdjustTool* self,
                                                    GtkWidget* widget,
                                                    GdkEventButton* event);
VALA_EXTERN gboolean has_only_key_modifier (GdkModifierType field,
                                GdkModifierType mask);
static void _editing_tools_adjust_tool_on_canvas_resize_editing_tools_photo_canvas_resized_scaled_pixbuf (EditingToolsPhotoCanvas* _sender,
                                                                                                   Dimensions* old_dim,
                                                                                                   GdkPixbuf* scaled,
                                                                                                   GdkRectangle* scaled_position,
                                                                                                   gpointer self);
static void _editing_tools_adjust_tool_on_ok_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self);
static void _editing_tools_adjust_tool_on_reset_gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self);
static void _editing_tools_adjust_tool_on_exposure_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                                gpointer self);
static void _editing_tools_adjust_tool_on_contrast_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                                gpointer self);
static void _editing_tools_adjust_tool_on_saturation_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                                  gpointer self);
static void _editing_tools_adjust_tool_on_tint_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                            gpointer self);
static void _editing_tools_adjust_tool_on_temperature_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                                   gpointer self);
static void _editing_tools_adjust_tool_on_shadows_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                               gpointer self);
static void _editing_tools_adjust_tool_on_highlights_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                                  gpointer self);
static void _editing_tools_adjust_tool_on_histogram_constraint_rgb_histogram_manipulator_nub_position_changed (RGBHistogramManipulator* _sender,
                                                                                                        gpointer self);
static gboolean _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event (GtkWidget* _sender,
                                                                                   GdkEventButton* event,
                                                                                   gpointer self);
VALA_EXTERN gboolean editing_tools_adjust_tool_enhance (EditingToolsAdjustTool* self);
static GType editing_tools_adjust_tool_adjust_enhance_command_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsAdjustToolAdjustEnhanceCommand, g_object_unref)
static EditingToolsAdjustToolAdjustEnhanceCommand* editing_tools_adjust_tool_adjust_enhance_command_new (EditingToolsAdjustTool* owner,
                                                                                                  Photo* photo);
static EditingToolsAdjustToolAdjustEnhanceCommand* editing_tools_adjust_tool_adjust_enhance_command_construct (GType object_type,
                                                                                                        EditingToolsAdjustTool* owner,
                                                                                                        Photo* photo);
static void editing_tools_adjust_tool_set_adjustments (EditingToolsAdjustTool* self,
                                                PixelTransformationBundle* new_adjustments);
static void editing_tools_adjust_tool_update_slider (EditingToolsAdjustTool* self,
                                              PixelTransformation* transformation);
static gboolean editing_tools_adjust_tool_real_on_keypress (EditingToolsEditingTool* base,
                                                     GdkEventKey* event);
VALA_EXTERN RGBHistogramManipulator* rgb_histogram_manipulator_new (void);
VALA_EXTERN RGBHistogramManipulator* rgb_histogram_manipulator_construct (GType object_type);
static void editing_tools_adjust_tool_adjust_tool_window_finalize (GObject * obj);
static GType editing_tools_adjust_tool_adjust_tool_window_get_type_once (void);
VALA_EXTERN GType command_description_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CommandDescription, g_object_unref)
static void editing_tools_adjust_tool_adjust_tool_command_on_owner_deactivated (EditingToolsAdjustToolAdjustToolCommand* self);
static void _editing_tools_adjust_tool_adjust_tool_command_on_owner_deactivated_editing_tools_editing_tool_deactivated (EditingToolsEditingTool* _sender,
                                                                                                                 gpointer self);
static EditingToolsAdjustToolAdjustToolCommand* editing_tools_adjust_tool_adjust_tool_command_construct (GType object_type,
                                                                                                  EditingToolsAdjustTool* owner,
                                                                                                  const gchar* name,
                                                                                                  const gchar* explanation);
VALA_EXTERN Command* command_construct (GType object_type,
                            const gchar* name,
                            const gchar* explanation);
VALA_EXTERN void command_manager_reset (CommandManager* self);
static void editing_tools_adjust_tool_adjust_tool_command_finalize (GObject * obj);
static GType editing_tools_adjust_tool_adjust_tool_command_get_type_once (void);
VALA_EXTERN void command_execute (Command* self);
VALA_EXTERN void command_undo (Command* self);
VALA_EXTERN gboolean command_compress (Command* self,
                           Command* command);
static void editing_tools_adjust_tool_adjust_reset_command_real_execute (Command* base);
static void editing_tools_adjust_tool_adjust_reset_command_real_undo (Command* base);
static gboolean editing_tools_adjust_tool_adjust_reset_command_real_compress (Command* base,
                                                                       Command* command);
static void editing_tools_adjust_tool_adjust_reset_command_finalize (GObject * obj);
static GType editing_tools_adjust_tool_adjust_reset_command_get_type_once (void);
VALA_EXTERN void command_redo (Command* self);
static void editing_tools_adjust_tool_slider_adjustment_command_real_execute (Command* base);
static void editing_tools_adjust_tool_slider_adjustment_command_real_undo (Command* base);
static void editing_tools_adjust_tool_slider_adjustment_command_real_redo (Command* base);
static gboolean editing_tools_adjust_tool_slider_adjustment_command_real_compress (Command* base,
                                                                            Command* command);
static void editing_tools_adjust_tool_slider_adjustment_command_finalize (GObject * obj);
static GType editing_tools_adjust_tool_slider_adjustment_command_get_type_once (void);
static void editing_tools_adjust_tool_adjust_enhance_command_real_execute (Command* base);
VALA_EXTERN PixelTransformationBundle* photo_get_enhance_transformations (Photo* self);
static void editing_tools_adjust_tool_adjust_enhance_command_real_undo (Command* base);
static gboolean editing_tools_adjust_tool_adjust_enhance_command_real_compress (Command* base,
                                                                         Command* command);
VALA_EXTERN GType enhance_single_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EnhanceSingleCommand, g_object_unref)
VALA_EXTERN DataSource* single_data_source_command_get_source (SingleDataSourceCommand* self);
VALA_EXTERN gboolean data_source_equals (DataSource* self,
                             DataSource* source);
static void editing_tools_adjust_tool_adjust_enhance_command_finalize (GObject * obj);
static GType editing_tools_adjust_tool_adjust_enhance_command_get_type_once (void);
static void editing_tools_adjust_tool_finalize (EditingToolsEditingTool * obj);
static GType editing_tools_adjust_tool_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

void
editing_tools_preconfigure (void)
{
}

void
editing_tools_init (GError** error)
{
}

void
editing_tools_terminate (void)
{
}

static inline gpointer
editing_tools_editing_tool_window_get_instance_private (EditingToolsEditingToolWindow* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsEditingToolWindow_private_offset);
}

static void
_editing_tools_editing_tool_window_suppress_warnings_glog_func (const gchar* log_domain,
                                                                GLogLevelFlags log_levels,
                                                                const gchar* message,
                                                                gpointer self)
{
	editing_tools_editing_tool_window_suppress_warnings ((EditingToolsEditingToolWindow*) self, log_domain, log_levels, message);
}

EditingToolsEditingToolWindow*
editing_tools_editing_tool_window_construct (GType object_type,
                                             GtkWindow* container)
{
	EditingToolsEditingToolWindow * self = NULL;
	GtkFrame* outer_frame = NULL;
	GtkFrame* _tmp0_;
	GtkFrame* _tmp1_;
	GtkFrame* _tmp2_;
	GtkFrame* _tmp3_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (container, gtk_window_get_type ()), NULL);
	self = (EditingToolsEditingToolWindow*) g_object_new (object_type, NULL);
	gtk_window_set_decorated (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), FALSE);
	gtk_window_set_transient_for (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), container);
	_tmp0_ = (GtkFrame*) gtk_frame_new (NULL);
	g_object_ref_sink (_tmp0_);
	outer_frame = _tmp0_;
	gtk_container_set_border_width (G_TYPE_CHECK_INSTANCE_CAST (outer_frame, gtk_container_get_type (), GtkContainer), (guint) 0);
	gtk_frame_set_shadow_type (outer_frame, GTK_SHADOW_OUT);
	_tmp1_ = self->priv->layout_frame;
	gtk_container_set_border_width (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_container_get_type (), GtkContainer), (guint) EDITING_TOOLS_EDITING_TOOL_WINDOW_FRAME_BORDER);
	_tmp2_ = self->priv->layout_frame;
	gtk_frame_set_shadow_type (_tmp2_, GTK_SHADOW_NONE);
	_tmp3_ = self->priv->layout_frame;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (outer_frame, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget));
	GTK_CONTAINER_CLASS (editing_tools_editing_tool_window_parent_class)->add (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (outer_frame, gtk_widget_get_type (), GtkWidget));
	gtk_widget_add_events (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), (gint) (GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK));
	gtk_window_set_focus_on_map (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), TRUE);
	gtk_window_set_accept_focus (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), TRUE);
	gtk_widget_set_can_focus (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), TRUE);
	g_log_set_handler ("Gdk", G_LOG_LEVEL_WARNING, _editing_tools_editing_tool_window_suppress_warnings_glog_func, self);
	_g_object_unref0 (outer_frame);
	return self;
}

static void
editing_tools_editing_tool_window_real_add (GtkContainer* base,
                                            GtkWidget* widget)
{
	EditingToolsEditingToolWindow * self;
	GtkFrame* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_widget_get_type ()));
	_tmp0_ = self->priv->layout_frame;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_container_get_type (), GtkContainer), widget);
}

gboolean
editing_tools_editing_tool_window_has_user_moved (EditingToolsEditingToolWindow* self)
{
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_IS_EDITING_TOOL_WINDOW (self), FALSE);
	result = self->priv->user_moved;
	return result;
}

static gboolean
editing_tools_editing_tool_window_real_key_press_event (GtkWidget* base,
                                                        GdkEventKey* event)
{
	EditingToolsEditingToolWindow * self;
	AppWindow* _tmp0_;
	AppWindow* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow);
	g_return_val_if_fail (event != NULL, FALSE);
	if (GTK_WIDGET_CLASS (editing_tools_editing_tool_window_parent_class)->key_press_event (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), gtk_widget_get_type (), GtkWidget), event)) {
		result = TRUE;
		return result;
	}
	_tmp0_ = app_window_get_instance ();
	_tmp1_ = _tmp0_;
	g_signal_emit_by_name (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget), "key-press-event", event, &_tmp2_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	result = _tmp3_;
	return result;
}

static gboolean
editing_tools_editing_tool_window_real_button_press_event (GtkWidget* base,
                                                           GdkEventButton* event)
{
	EditingToolsEditingToolWindow * self;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow);
	g_return_val_if_fail (event != NULL, FALSE);
	if (event->button != ((guint) 1)) {
		gboolean _tmp0_ = FALSE;
		if (GTK_WIDGET_CLASS (editing_tools_editing_tool_window_parent_class)->button_press_event != NULL) {
			_tmp0_ = GTK_WIDGET_CLASS (editing_tools_editing_tool_window_parent_class)->button_press_event (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), gtk_widget_get_type (), GtkWidget), event);
		} else {
			_tmp0_ = TRUE;
		}
		result = _tmp0_;
		return result;
	}
	gtk_window_begin_move_drag (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time);
	self->priv->user_moved = TRUE;
	result = TRUE;
	return result;
}

static void
editing_tools_editing_tool_window_real_realize (GtkWidget* base)
{
	EditingToolsEditingToolWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow);
	gtk_widget_set_opacity (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), RESOURCES_TRANSIENT_WINDOW_OPACITY);
	GTK_WIDGET_CLASS (editing_tools_editing_tool_window_parent_class)->realize (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), gtk_widget_get_type (), GtkWidget));
}

static void
editing_tools_editing_tool_window_suppress_warnings (EditingToolsEditingToolWindow* self,
                                                     const gchar* log_domain,
                                                     GLogLevelFlags log_levels,
                                                     const gchar* message)
{
	g_return_if_fail (EDITING_TOOLS_IS_EDITING_TOOL_WINDOW (self));
	g_return_if_fail (message != NULL);
}

static void
editing_tools_editing_tool_window_class_init (EditingToolsEditingToolWindowClass * klass,
                                              gpointer klass_data)
{
	editing_tools_editing_tool_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &EditingToolsEditingToolWindow_private_offset);
	((GtkContainerClass *) klass)->add = (void (*) (GtkContainer*, GtkWidget*)) editing_tools_editing_tool_window_real_add;
	((GtkWidgetClass *) klass)->key_press_event = (gboolean (*) (GtkWidget*, GdkEventKey*)) editing_tools_editing_tool_window_real_key_press_event;
	((GtkWidgetClass *) klass)->button_press_event = (gboolean (*) (GtkWidget*, GdkEventButton*)) editing_tools_editing_tool_window_real_button_press_event;
	((GtkWidgetClass *) klass)->realize = (void (*) (GtkWidget*)) editing_tools_editing_tool_window_real_realize;
	G_OBJECT_CLASS (klass)->finalize = editing_tools_editing_tool_window_finalize;
}

static void
editing_tools_editing_tool_window_instance_init (EditingToolsEditingToolWindow * self,
                                                 gpointer klass)
{
	GtkFrame* _tmp0_;
	self->priv = editing_tools_editing_tool_window_get_instance_private (self);
	_tmp0_ = (GtkFrame*) gtk_frame_new (NULL);
	g_object_ref_sink (_tmp0_);
	self->priv->layout_frame = _tmp0_;
	self->priv->user_moved = FALSE;
}

static void
editing_tools_editing_tool_window_finalize (GObject * obj)
{
	EditingToolsEditingToolWindow * self;
	GLogFunc _tmp0_;
	gpointer _tmp0__target;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow);
	_tmp0_ = g_log_default_handler;
	_tmp0__target = NULL;
	g_log_set_handler ("Gdk", G_LOG_LEVEL_WARNING, _tmp0_, _tmp0__target);
	_g_object_unref0 (self->priv->layout_frame);
	G_OBJECT_CLASS (editing_tools_editing_tool_window_parent_class)->finalize (obj);
}

static GType
editing_tools_editing_tool_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsEditingToolWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_editing_tool_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsEditingToolWindow), 0, (GInstanceInitFunc) editing_tools_editing_tool_window_instance_init, NULL };
	GType editing_tools_editing_tool_window_type_id;
	editing_tools_editing_tool_window_type_id = g_type_register_static (gtk_window_get_type (), "EditingToolsEditingToolWindow", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	EditingToolsEditingToolWindow_private_offset = g_type_add_instance_private (editing_tools_editing_tool_window_type_id, sizeof (EditingToolsEditingToolWindowPrivate));
	return editing_tools_editing_tool_window_type_id;
}

GType
editing_tools_editing_tool_window_get_type (void)
{
	static volatile gsize editing_tools_editing_tool_window_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_editing_tool_window_type_id__once)) {
		GType editing_tools_editing_tool_window_type_id;
		editing_tools_editing_tool_window_type_id = editing_tools_editing_tool_window_get_type_once ();
		g_once_init_leave (&editing_tools_editing_tool_window_type_id__once, editing_tools_editing_tool_window_type_id);
	}
	return editing_tools_editing_tool_window_type_id__once;
}

static inline gpointer
editing_tools_photo_canvas_get_instance_private (EditingToolsPhotoCanvas* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsPhotoCanvas_private_offset);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static gpointer
_cairo_reference0 (gpointer self)
{
	return self ? cairo_reference (self) : NULL;
}

EditingToolsPhotoCanvas*
editing_tools_photo_canvas_construct (GType object_type,
                                      GtkWindow* container,
                                      GdkWindow* drawing_window,
                                      Photo* photo,
                                      cairo_t* default_ctx,
                                      Dimensions* surface_dim,
                                      GdkPixbuf* scaled,
                                      GdkRectangle* scaled_position)
{
	EditingToolsPhotoCanvas* self = NULL;
	GtkWindow* _tmp0_;
	GdkWindow* _tmp1_;
	Photo* _tmp2_;
	cairo_t* _tmp3_;
	Dimensions _tmp4_;
	GdkRectangle _tmp5_;
	GdkPixbuf* _tmp6_;
	GdkRectangle _tmp7_;
	cairo_surface_t* _tmp8_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (container, gtk_window_get_type ()), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (drawing_window, gdk_window_get_type ()), NULL);
	g_return_val_if_fail (IS_PHOTO (photo), NULL);
	g_return_val_if_fail (default_ctx != NULL, NULL);
	g_return_val_if_fail (surface_dim != NULL, NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (scaled, gdk_pixbuf_get_type ()), NULL);
	g_return_val_if_fail (scaled_position != NULL, NULL);
	self = (EditingToolsPhotoCanvas*) g_type_create_instance (object_type);
	_tmp0_ = _g_object_ref0 (container);
	_g_object_unref0 (self->priv->container);
	self->priv->container = _tmp0_;
	_tmp1_ = _g_object_ref0 (drawing_window);
	_g_object_unref0 (self->priv->drawing_window);
	self->priv->drawing_window = _tmp1_;
	_tmp2_ = _g_object_ref0 (photo);
	_g_object_unref0 (self->priv->photo);
	self->priv->photo = _tmp2_;
	_tmp3_ = _cairo_reference0 (default_ctx);
	_cairo_destroy0 (self->priv->default_ctx);
	self->priv->default_ctx = _tmp3_;
	_tmp4_ = *surface_dim;
	self->priv->surface_dim = _tmp4_;
	_tmp5_ = *scaled_position;
	self->priv->scaled_position = _tmp5_;
	_tmp6_ = _g_object_ref0 (scaled);
	_g_object_unref0 (self->priv->scaled_pixbuf);
	self->priv->scaled_pixbuf = _tmp6_;
	_tmp7_ = *scaled_position;
	_tmp8_ = editing_tools_photo_canvas_pixbuf_to_surface (self, default_ctx, scaled, &_tmp7_);
	_cairo_surface_destroy0 (self->priv->scaled);
	self->priv->scaled = _tmp8_;
	return self;
}

void
editing_tools_photo_canvas_unscaled_to_raw_rect (EditingToolsPhotoCanvas* self,
                                                 GdkRectangle* rectangle,
                                                 GdkRectangle* result)
{
	Photo* _tmp0_;
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_ = {0};
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (rectangle != NULL);
	_tmp0_ = self->priv->photo;
	_tmp1_ = *rectangle;
	photo_unscaled_to_raw_rect (_tmp0_, &_tmp1_, &_tmp2_);
	*result = _tmp2_;
	return;
}

void
editing_tools_photo_canvas_active_to_unscaled_point (EditingToolsPhotoCanvas* self,
                                                     GdkPoint* active_point,
                                                     GdkPoint* result)
{
	GdkRectangle scaled_position = {0};
	GdkRectangle _tmp0_ = {0};
	Dimensions unscaled_dims = {0};
	Photo* _tmp1_;
	Dimensions _tmp2_ = {0};
	gdouble scale_factor_x = 0.0;
	Dimensions _tmp3_;
	GdkRectangle _tmp4_;
	gdouble scale_factor_y = 0.0;
	Dimensions _tmp5_;
	GdkRectangle _tmp6_;
	GdkPoint _result_ = {0};
	GdkPoint _tmp7_ = {0};
	GdkPoint _tmp8_;
	GdkPoint _tmp9_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (active_point != NULL);
	editing_tools_photo_canvas_get_scaled_pixbuf_position (self, &_tmp0_);
	scaled_position = _tmp0_;
	_tmp1_ = self->priv->photo;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_NONE, &_tmp2_);
	unscaled_dims = _tmp2_;
	_tmp3_ = unscaled_dims;
	_tmp4_ = scaled_position;
	scale_factor_x = ((gdouble) _tmp3_.width) / ((gdouble) _tmp4_.width);
	_tmp5_ = unscaled_dims;
	_tmp6_ = scaled_position;
	scale_factor_y = ((gdouble) _tmp5_.height) / ((gdouble) _tmp6_.height);
	_tmp7_.x = 0;
	_result_ = _tmp7_;
	_tmp8_ = *active_point;
	_result_.x = (gint) ((((gdouble) _tmp8_.x) * scale_factor_x) + 0.5);
	_tmp9_ = *active_point;
	_result_.y = (gint) ((((gdouble) _tmp9_.y) * scale_factor_y) + 0.5);
	*result = _result_;
	return;
}

void
editing_tools_photo_canvas_active_to_unscaled_rect (EditingToolsPhotoCanvas* self,
                                                    GdkRectangle* active_rect,
                                                    GdkRectangle* result)
{
	GdkPoint upper_left = {0};
	GdkPoint _tmp0_ = {0};
	GdkPoint lower_right = {0};
	GdkPoint _tmp1_ = {0};
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	GdkPoint _tmp4_;
	GdkRectangle _tmp5_;
	GdkPoint _tmp6_;
	GdkRectangle _tmp7_;
	GdkPoint _tmp8_;
	GdkPoint _tmp9_ = {0};
	GdkPoint _tmp10_;
	GdkPoint _tmp11_ = {0};
	GdkRectangle unscaled_rect = {0};
	GdkPoint _tmp12_;
	GdkPoint _tmp13_;
	GdkPoint _tmp14_;
	GdkPoint _tmp15_;
	GdkPoint _tmp16_;
	GdkPoint _tmp17_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (active_rect != NULL);
	_tmp0_.x = 0;
	upper_left = _tmp0_;
	_tmp1_.x = 0;
	lower_right = _tmp1_;
	_tmp2_ = *active_rect;
	upper_left.x = _tmp2_.x;
	_tmp3_ = *active_rect;
	upper_left.y = _tmp3_.y;
	_tmp4_ = upper_left;
	_tmp5_ = *active_rect;
	lower_right.x = _tmp4_.x + _tmp5_.width;
	_tmp6_ = upper_left;
	_tmp7_ = *active_rect;
	lower_right.y = _tmp6_.y + _tmp7_.height;
	_tmp8_ = upper_left;
	editing_tools_photo_canvas_active_to_unscaled_point (self, &_tmp8_, &_tmp9_);
	upper_left = _tmp9_;
	_tmp10_ = lower_right;
	editing_tools_photo_canvas_active_to_unscaled_point (self, &_tmp10_, &_tmp11_);
	lower_right = _tmp11_;
	memset (&unscaled_rect, 0, sizeof (GdkRectangle));
	_tmp12_ = upper_left;
	unscaled_rect.x = _tmp12_.x;
	_tmp13_ = upper_left;
	unscaled_rect.y = _tmp13_.y;
	_tmp14_ = lower_right;
	_tmp15_ = upper_left;
	unscaled_rect.width = _tmp14_.x - _tmp15_.x;
	_tmp16_ = lower_right;
	_tmp17_ = upper_left;
	unscaled_rect.height = _tmp16_.y - _tmp17_.y;
	*result = unscaled_rect;
	return;
}

void
editing_tools_photo_canvas_user_to_active_point (EditingToolsPhotoCanvas* self,
                                                 GdkPoint* user_point,
                                                 GdkPoint* result)
{
	GdkRectangle active_offsets = {0};
	GdkRectangle _tmp0_ = {0};
	GdkPoint _result_ = {0};
	GdkPoint _tmp1_ = {0};
	GdkPoint _tmp2_;
	GdkRectangle _tmp3_;
	GdkPoint _tmp4_;
	GdkRectangle _tmp5_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (user_point != NULL);
	editing_tools_photo_canvas_get_scaled_pixbuf_position (self, &_tmp0_);
	active_offsets = _tmp0_;
	_tmp1_.x = 0;
	_result_ = _tmp1_;
	_tmp2_ = *user_point;
	_tmp3_ = active_offsets;
	_result_.x = _tmp2_.x - _tmp3_.x;
	_tmp4_ = *user_point;
	_tmp5_ = active_offsets;
	_result_.y = _tmp4_.y - _tmp5_.y;
	*result = _result_;
	return;
}

void
editing_tools_photo_canvas_user_to_active_rect (EditingToolsPhotoCanvas* self,
                                                GdkRectangle* user_rect,
                                                GdkRectangle* result)
{
	GdkPoint upper_left = {0};
	GdkPoint _tmp0_ = {0};
	GdkPoint lower_right = {0};
	GdkPoint _tmp1_ = {0};
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	GdkPoint _tmp4_;
	GdkRectangle _tmp5_;
	GdkPoint _tmp6_;
	GdkRectangle _tmp7_;
	GdkPoint _tmp8_;
	GdkPoint _tmp9_ = {0};
	GdkPoint _tmp10_;
	GdkPoint _tmp11_ = {0};
	GdkRectangle active_rect = {0};
	GdkPoint _tmp12_;
	GdkPoint _tmp13_;
	GdkPoint _tmp14_;
	GdkPoint _tmp15_;
	GdkPoint _tmp16_;
	GdkPoint _tmp17_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (user_rect != NULL);
	_tmp0_.x = 0;
	upper_left = _tmp0_;
	_tmp1_.x = 0;
	lower_right = _tmp1_;
	_tmp2_ = *user_rect;
	upper_left.x = _tmp2_.x;
	_tmp3_ = *user_rect;
	upper_left.y = _tmp3_.y;
	_tmp4_ = upper_left;
	_tmp5_ = *user_rect;
	lower_right.x = _tmp4_.x + _tmp5_.width;
	_tmp6_ = upper_left;
	_tmp7_ = *user_rect;
	lower_right.y = _tmp6_.y + _tmp7_.height;
	_tmp8_ = upper_left;
	editing_tools_photo_canvas_user_to_active_point (self, &_tmp8_, &_tmp9_);
	upper_left = _tmp9_;
	_tmp10_ = lower_right;
	editing_tools_photo_canvas_user_to_active_point (self, &_tmp10_, &_tmp11_);
	lower_right = _tmp11_;
	memset (&active_rect, 0, sizeof (GdkRectangle));
	_tmp12_ = upper_left;
	active_rect.x = _tmp12_.x;
	_tmp13_ = upper_left;
	active_rect.y = _tmp13_.y;
	_tmp14_ = lower_right;
	_tmp15_ = upper_left;
	active_rect.width = _tmp14_.x - _tmp15_.x;
	_tmp16_ = lower_right;
	_tmp17_ = upper_left;
	active_rect.height = _tmp16_.y - _tmp17_.y;
	*result = active_rect;
	return;
}

Photo*
editing_tools_photo_canvas_get_photo (EditingToolsPhotoCanvas* self)
{
	Photo* _tmp0_;
	Photo* _tmp1_;
	Photo* result;
	g_return_val_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self), NULL);
	_tmp0_ = self->priv->photo;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

GtkWindow*
editing_tools_photo_canvas_get_container (EditingToolsPhotoCanvas* self)
{
	GtkWindow* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* result;
	g_return_val_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self), NULL);
	_tmp0_ = self->priv->container;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

GdkWindow*
editing_tools_photo_canvas_get_drawing_window (EditingToolsPhotoCanvas* self)
{
	GdkWindow* _tmp0_;
	GdkWindow* _tmp1_;
	GdkWindow* result;
	g_return_val_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self), NULL);
	_tmp0_ = self->priv->drawing_window;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

cairo_t*
editing_tools_photo_canvas_get_default_ctx (EditingToolsPhotoCanvas* self)
{
	cairo_t* _tmp0_;
	cairo_t* _tmp1_;
	cairo_t* result;
	g_return_val_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self), NULL);
	_tmp0_ = self->priv->default_ctx;
	_tmp1_ = _cairo_reference0 (_tmp0_);
	result = _tmp1_;
	return result;
}

void
editing_tools_photo_canvas_get_surface_dim (EditingToolsPhotoCanvas* self,
                                            Dimensions* result)
{
	Dimensions _tmp0_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	_tmp0_ = self->priv->surface_dim;
	*result = _tmp0_;
	return;
}

void
editing_tools_photo_canvas_get_scaling (EditingToolsPhotoCanvas* self,
                                        Scaling* result)
{
	Dimensions _tmp0_;
	Scaling _tmp1_ = {0};
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	_tmp0_ = self->priv->surface_dim;
	scaling_for_viewport (&_tmp0_, FALSE, &_tmp1_);
	*result = _tmp1_;
	return;
}

void
editing_tools_photo_canvas_set_surface (EditingToolsPhotoCanvas* self,
                                        cairo_t* default_ctx,
                                        Dimensions* surface_dim)
{
	cairo_t* _tmp0_;
	Dimensions _tmp1_;
	Dimensions _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (default_ctx != NULL);
	g_return_if_fail (surface_dim != NULL);
	_tmp0_ = _cairo_reference0 (default_ctx);
	_cairo_destroy0 (self->priv->default_ctx);
	self->priv->default_ctx = _tmp0_;
	_tmp1_ = *surface_dim;
	self->priv->surface_dim = _tmp1_;
	_tmp2_ = *surface_dim;
	g_signal_emit (self, editing_tools_photo_canvas_signals[EDITING_TOOLS_PHOTO_CANVAS_NEW_SURFACE_SIGNAL], 0, default_ctx, &_tmp2_);
}

static gpointer
_cairo_surface_reference0 (gpointer self)
{
	return self ? cairo_surface_reference (self) : NULL;
}

cairo_surface_t*
editing_tools_photo_canvas_get_scaled_surface (EditingToolsPhotoCanvas* self)
{
	cairo_surface_t* _tmp0_;
	cairo_surface_t* _tmp1_;
	cairo_surface_t* result;
	g_return_val_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self), NULL);
	_tmp0_ = self->priv->scaled;
	_tmp1_ = _cairo_surface_reference0 (_tmp0_);
	result = _tmp1_;
	return result;
}

GdkPixbuf*
editing_tools_photo_canvas_get_scaled_pixbuf (EditingToolsPhotoCanvas* self)
{
	GdkPixbuf* _tmp0_;
	GdkPixbuf* _tmp1_;
	GdkPixbuf* result;
	g_return_val_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self), NULL);
	_tmp0_ = self->priv->scaled_pixbuf;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

void
editing_tools_photo_canvas_get_scaled_pixbuf_position (EditingToolsPhotoCanvas* self,
                                                       GdkRectangle* result)
{
	GdkRectangle _tmp0_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	_tmp0_ = self->priv->scaled_position;
	*result = _tmp0_;
	return;
}

void
editing_tools_photo_canvas_resized_pixbuf (EditingToolsPhotoCanvas* self,
                                           Dimensions* old_dim,
                                           GdkPixbuf* scaled,
                                           GdkRectangle* scaled_position)
{
	cairo_t* _tmp0_;
	GdkRectangle _tmp1_;
	cairo_surface_t* _tmp2_;
	GdkPixbuf* _tmp3_;
	GdkRectangle _tmp4_;
	Dimensions _tmp5_;
	GdkRectangle _tmp6_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (old_dim != NULL);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (scaled, gdk_pixbuf_get_type ()));
	g_return_if_fail (scaled_position != NULL);
	_tmp0_ = self->priv->default_ctx;
	_tmp1_ = *scaled_position;
	_tmp2_ = editing_tools_photo_canvas_pixbuf_to_surface (self, _tmp0_, scaled, &_tmp1_);
	_cairo_surface_destroy0 (self->priv->scaled);
	self->priv->scaled = _tmp2_;
	_tmp3_ = _g_object_ref0 (scaled);
	_g_object_unref0 (self->priv->scaled_pixbuf);
	self->priv->scaled_pixbuf = _tmp3_;
	_tmp4_ = *scaled_position;
	self->priv->scaled_position = _tmp4_;
	_tmp5_ = *old_dim;
	_tmp6_ = *scaled_position;
	g_signal_emit (self, editing_tools_photo_canvas_signals[EDITING_TOOLS_PHOTO_CANVAS_RESIZED_SCALED_PIXBUF_SIGNAL], 0, &_tmp5_, scaled, &_tmp6_);
}

static void
editing_tools_photo_canvas_real_repaint (EditingToolsPhotoCanvas* self)
{
	g_critical ("Type `%s' does not implement abstract method `editing_tools_photo_canvas_repaint'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
editing_tools_photo_canvas_repaint (EditingToolsPhotoCanvas* self)
{
	EditingToolsPhotoCanvasClass* _klass_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	_klass_ = EDITING_TOOLS_PHOTO_CANVAS_GET_CLASS (self);
	if (_klass_->repaint) {
		_klass_->repaint (self);
	}
}

void
editing_tools_photo_canvas_paint_pixbuf (EditingToolsPhotoCanvas* self,
                                         GdkPixbuf* pixbuf)
{
	cairo_t* _tmp0_;
	cairo_t* _tmp1_;
	cairo_t* _tmp2_;
	Dimensions _tmp3_;
	Dimensions _tmp4_;
	cairo_t* _tmp5_;
	cairo_t* _tmp6_;
	GdkRectangle _tmp7_;
	GdkRectangle _tmp8_;
	cairo_t* _tmp9_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (pixbuf, gdk_pixbuf_get_type ()));
	_tmp0_ = self->priv->default_ctx;
	cairo_save (_tmp0_);
	_tmp1_ = self->priv->default_ctx;
	set_source_color_from_string (_tmp1_, "#000");
	_tmp2_ = self->priv->default_ctx;
	_tmp3_ = self->priv->surface_dim;
	_tmp4_ = self->priv->surface_dim;
	cairo_rectangle (_tmp2_, (gdouble) 0, (gdouble) 0, (gdouble) _tmp3_.width, (gdouble) _tmp4_.height);
	_tmp5_ = self->priv->default_ctx;
	cairo_fill (_tmp5_);
	_tmp6_ = self->priv->default_ctx;
	_tmp7_ = self->priv->scaled_position;
	_tmp8_ = self->priv->scaled_position;
	paint_pixmap_with_background (_tmp6_, pixbuf, _tmp7_.x, _tmp8_.y);
	_tmp9_ = self->priv->default_ctx;
	cairo_restore (_tmp9_);
}

void
editing_tools_photo_canvas_paint_surface (EditingToolsPhotoCanvas* self,
                                          cairo_surface_t* surface,
                                          gboolean over)
{
	cairo_t* _tmp0_;
	cairo_t* _tmp3_;
	cairo_surface_t* _tmp4_;
	GdkRectangle _tmp5_;
	GdkRectangle _tmp6_;
	cairo_t* _tmp7_;
	cairo_t* _tmp8_;
	GdkRectangle _tmp9_;
	GdkRectangle _tmp10_;
	cairo_t* _tmp11_;
	cairo_t* _tmp12_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (surface != NULL);
	_tmp0_ = self->priv->default_ctx;
	cairo_save (_tmp0_);
	if (over == FALSE) {
		cairo_t* _tmp1_;
		_tmp1_ = self->priv->default_ctx;
		cairo_set_operator (_tmp1_, CAIRO_OPERATOR_SOURCE);
	} else {
		cairo_t* _tmp2_;
		_tmp2_ = self->priv->default_ctx;
		cairo_set_operator (_tmp2_, CAIRO_OPERATOR_OVER);
	}
	_tmp3_ = self->priv->default_ctx;
	_tmp4_ = self->priv->scaled;
	_tmp5_ = self->priv->scaled_position;
	_tmp6_ = self->priv->scaled_position;
	cairo_set_source_surface (_tmp3_, _tmp4_, (gdouble) _tmp5_.x, (gdouble) _tmp6_.y);
	_tmp7_ = self->priv->default_ctx;
	cairo_paint (_tmp7_);
	_tmp8_ = self->priv->default_ctx;
	_tmp9_ = self->priv->scaled_position;
	_tmp10_ = self->priv->scaled_position;
	cairo_set_source_surface (_tmp8_, surface, (gdouble) _tmp9_.x, (gdouble) _tmp10_.y);
	_tmp11_ = self->priv->default_ctx;
	cairo_paint (_tmp11_);
	_tmp12_ = self->priv->default_ctx;
	cairo_restore (_tmp12_);
}

void
editing_tools_photo_canvas_paint_surface_area (EditingToolsPhotoCanvas* self,
                                               cairo_surface_t* surface,
                                               Box* source_area,
                                               gboolean over)
{
	cairo_t* _tmp0_;
	cairo_t* _tmp3_;
	cairo_surface_t* _tmp4_;
	GdkRectangle _tmp5_;
	GdkRectangle _tmp6_;
	cairo_t* _tmp7_;
	GdkRectangle _tmp8_;
	Box _tmp9_;
	GdkRectangle _tmp10_;
	Box _tmp11_;
	cairo_t* _tmp12_;
	cairo_t* _tmp13_;
	GdkRectangle _tmp14_;
	GdkRectangle _tmp15_;
	cairo_t* _tmp16_;
	GdkRectangle _tmp17_;
	Box _tmp18_;
	GdkRectangle _tmp19_;
	Box _tmp20_;
	cairo_t* _tmp21_;
	cairo_t* _tmp22_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (surface != NULL);
	g_return_if_fail (source_area != NULL);
	_tmp0_ = self->priv->default_ctx;
	cairo_save (_tmp0_);
	if (over == FALSE) {
		cairo_t* _tmp1_;
		_tmp1_ = self->priv->default_ctx;
		cairo_set_operator (_tmp1_, CAIRO_OPERATOR_SOURCE);
	} else {
		cairo_t* _tmp2_;
		_tmp2_ = self->priv->default_ctx;
		cairo_set_operator (_tmp2_, CAIRO_OPERATOR_OVER);
	}
	_tmp3_ = self->priv->default_ctx;
	_tmp4_ = self->priv->scaled;
	_tmp5_ = self->priv->scaled_position;
	_tmp6_ = self->priv->scaled_position;
	cairo_set_source_surface (_tmp3_, _tmp4_, (gdouble) _tmp5_.x, (gdouble) _tmp6_.y);
	_tmp7_ = self->priv->default_ctx;
	_tmp8_ = self->priv->scaled_position;
	_tmp9_ = *source_area;
	_tmp10_ = self->priv->scaled_position;
	_tmp11_ = *source_area;
	cairo_rectangle (_tmp7_, (gdouble) (_tmp8_.x + _tmp9_.left), (gdouble) (_tmp10_.y + _tmp11_.top), (gdouble) box_get_width (source_area), (gdouble) box_get_height (source_area));
	_tmp12_ = self->priv->default_ctx;
	cairo_fill (_tmp12_);
	_tmp13_ = self->priv->default_ctx;
	_tmp14_ = self->priv->scaled_position;
	_tmp15_ = self->priv->scaled_position;
	cairo_set_source_surface (_tmp13_, surface, (gdouble) _tmp14_.x, (gdouble) _tmp15_.y);
	_tmp16_ = self->priv->default_ctx;
	_tmp17_ = self->priv->scaled_position;
	_tmp18_ = *source_area;
	_tmp19_ = self->priv->scaled_position;
	_tmp20_ = *source_area;
	cairo_rectangle (_tmp16_, (gdouble) (_tmp17_.x + _tmp18_.left), (gdouble) (_tmp19_.y + _tmp20_.top), (gdouble) box_get_width (source_area), (gdouble) box_get_height (source_area));
	_tmp21_ = self->priv->default_ctx;
	cairo_fill (_tmp21_);
	_tmp22_ = self->priv->default_ctx;
	cairo_restore (_tmp22_);
}

void
editing_tools_photo_canvas_draw_box (EditingToolsPhotoCanvas* self,
                                     cairo_t* ctx,
                                     Box* box)
{
	GdkRectangle rect = {0};
	GdkRectangle _tmp0_ = {0};
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	GdkRectangle _tmp4_;
	GdkRectangle _tmp5_;
	GdkRectangle _tmp6_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (box != NULL);
	box_get_rectangle (box, &_tmp0_);
	rect = _tmp0_;
	_tmp1_ = self->priv->scaled_position;
	rect.x = rect.x + _tmp1_.x;
	_tmp2_ = self->priv->scaled_position;
	rect.y = rect.y + _tmp2_.y;
	_tmp3_ = rect;
	_tmp4_ = rect;
	_tmp5_ = rect;
	_tmp6_ = rect;
	cairo_rectangle (ctx, _tmp3_.x + 0.5, _tmp4_.y + 0.5, (gdouble) (_tmp5_.width - 1), (gdouble) (_tmp6_.height - 1));
	cairo_stroke (ctx);
}

void
editing_tools_photo_canvas_draw_text (EditingToolsPhotoCanvas* self,
                                      cairo_t* ctx,
                                      const gchar* text,
                                      gint x,
                                      gint y,
                                      gboolean use_scaled_pos)
{
	cairo_text_extents_t extents = {0};
	cairo_text_extents_t _tmp2_ = {0};
	cairo_text_extents_t _tmp3_;
	gint pane_border = 0;
	cairo_text_extents_t _tmp4_;
	cairo_text_extents_t _tmp5_;
	cairo_text_extents_t _tmp6_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (text != NULL);
	if (use_scaled_pos) {
		GdkRectangle _tmp0_;
		GdkRectangle _tmp1_;
		_tmp0_ = self->priv->scaled_position;
		x = x + _tmp0_.x;
		_tmp1_ = self->priv->scaled_position;
		y = y + _tmp1_.y;
	}
	cairo_text_extents (ctx, text, &_tmp2_);
	extents = _tmp2_;
	_tmp3_ = extents;
	x = x - (((gint) _tmp3_.width) / 2);
	set_source_color_from_string (ctx, RESOURCES_ONIMAGE_FONT_BACKGROUND);
	pane_border = 5;
	_tmp4_ = extents;
	_tmp5_ = extents;
	_tmp6_ = extents;
	cairo_rectangle (ctx, (gdouble) (x - pane_border), (y - pane_border) - _tmp4_.height, _tmp5_.width + (2 * pane_border), _tmp6_.height + (2 * pane_border));
	cairo_fill (ctx);
	cairo_move_to (ctx, (gdouble) x, (gdouble) y);
	set_source_color_from_string (ctx, RESOURCES_ONIMAGE_FONT_COLOR);
	cairo_show_text (ctx, text);
}

/**
     * Draw a horizontal line into the specified Cairo context at the specified position, taking
     * into account the scaled position of the image unless directed otherwise.
     *
     * @param ctx The drawing context of the surface we're drawing to.
     * @param x The horizontal position to place the line at.
     * @param y The vertical position to place the line at.
     * @param width The length of the line.
     * @param use_scaled_pos Whether to use absolute window positioning or take into account the 
     *      position of the scaled image.
     */
void
editing_tools_photo_canvas_draw_horizontal_line (EditingToolsPhotoCanvas* self,
                                                 cairo_t* ctx,
                                                 gint x,
                                                 gint y,
                                                 gint width,
                                                 gboolean use_scaled_pos)
{
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (ctx != NULL);
	if (use_scaled_pos) {
		GdkRectangle _tmp0_;
		GdkRectangle _tmp1_;
		_tmp0_ = self->priv->scaled_position;
		x = x + _tmp0_.x;
		_tmp1_ = self->priv->scaled_position;
		y = y + _tmp1_.y;
	}
	cairo_move_to (ctx, x + 0.5, y + 0.5);
	cairo_line_to (ctx, (gdouble) ((x + width) - 1), y + 0.5);
	cairo_stroke (ctx);
}

/**
     * Draw a vertical line into the specified Cairo context at the specified position, taking
     * into account the scaled position of the image unless directed otherwise.
     *
     * @param ctx The drawing context of the surface we're drawing to.
     * @param x The horizontal position to place the line at.
     * @param y The vertical position to place the line at.
     * @param width The length of the line.
     * @param use_scaled_pos Whether to use absolute window positioning or take into account the 
     *      position of the scaled image.
     */
void
editing_tools_photo_canvas_draw_vertical_line (EditingToolsPhotoCanvas* self,
                                               cairo_t* ctx,
                                               gint x,
                                               gint y,
                                               gint height,
                                               gboolean use_scaled_pos)
{
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (ctx != NULL);
	if (use_scaled_pos) {
		GdkRectangle _tmp0_;
		GdkRectangle _tmp1_;
		_tmp0_ = self->priv->scaled_position;
		x = x + _tmp0_.x;
		_tmp1_ = self->priv->scaled_position;
		y = y + _tmp1_.y;
	}
	cairo_move_to (ctx, x + 0.5, y + 0.5);
	cairo_line_to (ctx, x + 0.5, (gdouble) ((y + height) - 1));
	cairo_stroke (ctx);
}

void
editing_tools_photo_canvas_erase_horizontal_line (EditingToolsPhotoCanvas* self,
                                                  gint x,
                                                  gint y,
                                                  gint width)
{
	gdouble scale = 0.0;
	cairo_t* _tmp0_;
	cairo_t* _tmp1_;
	cairo_t* _tmp2_;
	cairo_surface_t* _tmp3_;
	GdkRectangle _tmp4_;
	GdkRectangle _tmp5_;
	cairo_t* _tmp6_;
	GdkRectangle _tmp7_;
	GdkRectangle _tmp8_;
	cairo_t* _tmp9_;
	cairo_t* _tmp10_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	scale = application_get_scale ();
	_tmp0_ = self->priv->default_ctx;
	cairo_save (_tmp0_);
	_tmp1_ = self->priv->default_ctx;
	cairo_set_operator (_tmp1_, CAIRO_OPERATOR_SOURCE);
	_tmp2_ = self->priv->default_ctx;
	_tmp3_ = self->priv->scaled;
	_tmp4_ = self->priv->scaled_position;
	_tmp5_ = self->priv->scaled_position;
	cairo_set_source_surface (_tmp2_, _tmp3_, (gdouble) _tmp4_.x, (gdouble) _tmp5_.y);
	_tmp6_ = self->priv->default_ctx;
	_tmp7_ = self->priv->scaled_position;
	_tmp8_ = self->priv->scaled_position;
	cairo_rectangle (_tmp6_, (gdouble) (_tmp7_.x + x), (gdouble) (_tmp8_.y + y), (gdouble) (width - 1), 1 * scale);
	_tmp9_ = self->priv->default_ctx;
	cairo_fill (_tmp9_);
	_tmp10_ = self->priv->default_ctx;
	cairo_restore (_tmp10_);
}

void
editing_tools_photo_canvas_draw_circle (EditingToolsPhotoCanvas* self,
                                        cairo_t* ctx,
                                        gint active_center_x,
                                        gint active_center_y,
                                        gint radius)
{
	gint center_x = 0;
	GdkRectangle _tmp0_;
	gint center_y = 0;
	GdkRectangle _tmp1_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (ctx != NULL);
	_tmp0_ = self->priv->scaled_position;
	center_x = active_center_x + _tmp0_.x;
	_tmp1_ = self->priv->scaled_position;
	center_y = active_center_y + _tmp1_.y;
	cairo_arc (ctx, (gdouble) center_x, (gdouble) center_y, (gdouble) radius, (gdouble) 0, 2 * G_PI);
	cairo_stroke (ctx);
}

void
editing_tools_photo_canvas_erase_vertical_line (EditingToolsPhotoCanvas* self,
                                                gint x,
                                                gint y,
                                                gint height)
{
	cairo_t* _tmp0_;
	gdouble scale = 0.0;
	cairo_t* _tmp1_;
	cairo_t* _tmp2_;
	cairo_surface_t* _tmp3_;
	GdkRectangle _tmp4_;
	GdkRectangle _tmp5_;
	cairo_t* _tmp6_;
	GdkRectangle _tmp7_;
	GdkRectangle _tmp8_;
	cairo_t* _tmp9_;
	cairo_t* _tmp10_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	_tmp0_ = self->priv->default_ctx;
	cairo_save (_tmp0_);
	scale = application_get_scale ();
	_tmp1_ = self->priv->default_ctx;
	cairo_set_operator (_tmp1_, CAIRO_OPERATOR_SOURCE);
	_tmp2_ = self->priv->default_ctx;
	_tmp3_ = self->priv->scaled;
	_tmp4_ = self->priv->scaled_position;
	_tmp5_ = self->priv->scaled_position;
	cairo_set_source_surface (_tmp2_, _tmp3_, (gdouble) _tmp4_.x, (gdouble) _tmp5_.y);
	_tmp6_ = self->priv->default_ctx;
	_tmp7_ = self->priv->scaled_position;
	_tmp8_ = self->priv->scaled_position;
	cairo_rectangle (_tmp6_, (gdouble) (_tmp7_.x + x), (gdouble) (_tmp8_.y + y), 1 * scale, (gdouble) height);
	_tmp9_ = self->priv->default_ctx;
	cairo_fill (_tmp9_);
	_tmp10_ = self->priv->default_ctx;
	cairo_restore (_tmp10_);
}

void
editing_tools_photo_canvas_erase_box (EditingToolsPhotoCanvas* self,
                                      Box* box)
{
	Box _tmp0_;
	Box _tmp1_;
	Box _tmp2_;
	Box _tmp3_;
	Box _tmp4_;
	Box _tmp5_;
	Box _tmp6_;
	Box _tmp7_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (box != NULL);
	_tmp0_ = *box;
	_tmp1_ = *box;
	editing_tools_photo_canvas_erase_horizontal_line (self, _tmp0_.left, _tmp1_.top, box_get_width (box));
	_tmp2_ = *box;
	_tmp3_ = *box;
	editing_tools_photo_canvas_erase_horizontal_line (self, _tmp2_.left, _tmp3_.bottom, box_get_width (box));
	_tmp4_ = *box;
	_tmp5_ = *box;
	editing_tools_photo_canvas_erase_vertical_line (self, _tmp4_.left, _tmp5_.top, box_get_height (box));
	_tmp6_ = *box;
	_tmp7_ = *box;
	editing_tools_photo_canvas_erase_vertical_line (self, _tmp6_.right, _tmp7_.top, box_get_height (box));
}

void
editing_tools_photo_canvas_invalidate_area (EditingToolsPhotoCanvas* self,
                                            Box* area)
{
	GdkRectangle rect = {0};
	GdkRectangle _tmp0_ = {0};
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_;
	GdkWindow* _tmp3_;
	GdkRectangle _tmp4_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	g_return_if_fail (area != NULL);
	box_get_rectangle (area, &_tmp0_);
	rect = _tmp0_;
	_tmp1_ = self->priv->scaled_position;
	rect.x = rect.x + _tmp1_.x;
	_tmp2_ = self->priv->scaled_position;
	rect.y = rect.y + _tmp2_.y;
	_tmp3_ = self->priv->drawing_window;
	_tmp4_ = rect;
	gdk_window_invalidate_rect (_tmp3_, &_tmp4_, FALSE);
}

void
editing_tools_photo_canvas_set_cursor (EditingToolsPhotoCanvas* self,
                                       GdkCursorType cursor_type)
{
	GdkDisplay* display = NULL;
	GdkWindow* _tmp0_;
	GdkWindow* _tmp1_;
	GdkDisplay* _tmp2_;
	GdkDisplay* _tmp3_;
	GdkDisplay* _tmp4_;
	GdkCursor* cursor = NULL;
	GdkCursor* _tmp5_;
	GdkWindow* _tmp6_;
	GdkWindow* _tmp7_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self));
	_tmp0_ = editing_tools_photo_canvas_get_drawing_window (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = gdk_window_get_display (_tmp1_);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp1_);
	display = _tmp4_;
	_tmp5_ = gdk_cursor_new_for_display (display, cursor_type);
	cursor = _tmp5_;
	_tmp6_ = editing_tools_photo_canvas_get_drawing_window (self);
	_tmp7_ = _tmp6_;
	gdk_window_set_cursor (_tmp7_, cursor);
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (cursor);
	_g_object_unref0 (display);
}

static cairo_surface_t*
editing_tools_photo_canvas_pixbuf_to_surface (EditingToolsPhotoCanvas* self,
                                              cairo_t* default_ctx,
                                              GdkPixbuf* pixbuf,
                                              GdkRectangle* pos)
{
	cairo_surface_t* surface = NULL;
	cairo_surface_t* _tmp0_;
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_;
	cairo_surface_t* _tmp3_;
	cairo_t* ctx = NULL;
	cairo_t* _tmp4_;
	cairo_surface_t* result;
	g_return_val_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (self), NULL);
	g_return_val_if_fail (default_ctx != NULL, NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (pixbuf, gdk_pixbuf_get_type ()), NULL);
	g_return_val_if_fail (pos != NULL, NULL);
	_tmp0_ = cairo_get_target (default_ctx);
	_tmp1_ = *pos;
	_tmp2_ = *pos;
	_tmp3_ = cairo_surface_create_similar (_tmp0_, CAIRO_CONTENT_COLOR_ALPHA, _tmp1_.width, _tmp2_.height);
	surface = _tmp3_;
	_tmp4_ = cairo_create (surface);
	ctx = _tmp4_;
	paint_pixmap_with_background (ctx, pixbuf, 0, 0);
	cairo_paint (ctx);
	result = surface;
	_cairo_destroy0 (ctx);
	return result;
}

static void
g_cclosure_user_marshal_VOID__BOXED_BOXED (GClosure * closure,
                                           GValue * return_value,
                                           guint n_param_values,
                                           const GValue * param_values,
                                           gpointer invocation_hint,
                                           gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__BOXED_BOXED) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__BOXED_BOXED callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__BOXED_BOXED) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_boxed (param_values + 1), g_value_get_boxed (param_values + 2), data2);
}

static void
g_cclosure_user_marshal_VOID__BOXED_OBJECT_BOXED (GClosure * closure,
                                                  GValue * return_value,
                                                  guint n_param_values,
                                                  const GValue * param_values,
                                                  gpointer invocation_hint,
                                                  gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__BOXED_OBJECT_BOXED) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer arg_3, gpointer data2);
	register GMarshalFunc_VOID__BOXED_OBJECT_BOXED callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 4);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__BOXED_OBJECT_BOXED) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_boxed (param_values + 1), g_value_get_object (param_values + 2), g_value_get_boxed (param_values + 3), data2);
}

static void
editing_tools_value_photo_canvas_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
editing_tools_value_photo_canvas_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		editing_tools_photo_canvas_unref (value->data[0].v_pointer);
	}
}

static void
editing_tools_value_photo_canvas_copy_value (const GValue* src_value,
                                             GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = editing_tools_photo_canvas_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
editing_tools_value_photo_canvas_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
editing_tools_value_photo_canvas_collect_value (GValue* value,
                                                guint n_collect_values,
                                                GTypeCValue* collect_values,
                                                guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		EditingToolsPhotoCanvas * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = editing_tools_photo_canvas_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
editing_tools_value_photo_canvas_lcopy_value (const GValue* value,
                                              guint n_collect_values,
                                              GTypeCValue* collect_values,
                                              guint collect_flags)
{
	EditingToolsPhotoCanvas ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = editing_tools_photo_canvas_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
editing_tools_param_spec_photo_canvas (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags)
{
	EditingToolsParamSpecPhotoCanvas* spec;
	g_return_val_if_fail (g_type_is_a (object_type, EDITING_TOOLS_TYPE_PHOTO_CANVAS), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
editing_tools_value_get_photo_canvas (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EDITING_TOOLS_TYPE_PHOTO_CANVAS), NULL);
	return value->data[0].v_pointer;
}

void
editing_tools_value_set_photo_canvas (GValue* value,
                                      gpointer v_object)
{
	EditingToolsPhotoCanvas * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EDITING_TOOLS_TYPE_PHOTO_CANVAS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EDITING_TOOLS_TYPE_PHOTO_CANVAS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		editing_tools_photo_canvas_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		editing_tools_photo_canvas_unref (old);
	}
}

void
editing_tools_value_take_photo_canvas (GValue* value,
                                       gpointer v_object)
{
	EditingToolsPhotoCanvas * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EDITING_TOOLS_TYPE_PHOTO_CANVAS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EDITING_TOOLS_TYPE_PHOTO_CANVAS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		editing_tools_photo_canvas_unref (old);
	}
}

static void
editing_tools_photo_canvas_class_init (EditingToolsPhotoCanvasClass * klass,
                                       gpointer klass_data)
{
	editing_tools_photo_canvas_parent_class = g_type_class_peek_parent (klass);
	((EditingToolsPhotoCanvasClass *) klass)->finalize = editing_tools_photo_canvas_finalize;
	g_type_class_adjust_private_offset (klass, &EditingToolsPhotoCanvas_private_offset);
	((EditingToolsPhotoCanvasClass *) klass)->repaint = (void (*) (EditingToolsPhotoCanvas*)) editing_tools_photo_canvas_real_repaint;
	editing_tools_photo_canvas_signals[EDITING_TOOLS_PHOTO_CANVAS_NEW_SURFACE_SIGNAL] = g_signal_new ("new-surface", EDITING_TOOLS_TYPE_PHOTO_CANVAS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__BOXED_BOXED, G_TYPE_NONE, 2, cairo_gobject_context_get_type (), TYPE_DIMENSIONS);
	editing_tools_photo_canvas_signals[EDITING_TOOLS_PHOTO_CANVAS_RESIZED_SCALED_PIXBUF_SIGNAL] = g_signal_new ("resized-scaled-pixbuf", EDITING_TOOLS_TYPE_PHOTO_CANVAS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__BOXED_OBJECT_BOXED, G_TYPE_NONE, 3, TYPE_DIMENSIONS, gdk_pixbuf_get_type (), gdk_rectangle_get_type ());
}

static void
editing_tools_photo_canvas_instance_init (EditingToolsPhotoCanvas * self,
                                          gpointer klass)
{
	self->priv = editing_tools_photo_canvas_get_instance_private (self);
	self->ref_count = 1;
}

static void
editing_tools_photo_canvas_finalize (EditingToolsPhotoCanvas * obj)
{
	EditingToolsPhotoCanvas * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_TYPE_PHOTO_CANVAS, EditingToolsPhotoCanvas);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->container);
	_g_object_unref0 (self->priv->drawing_window);
	_g_object_unref0 (self->priv->photo);
	_cairo_destroy0 (self->priv->default_ctx);
	_cairo_surface_destroy0 (self->priv->scaled);
	_g_object_unref0 (self->priv->scaled_pixbuf);
}

static GType
editing_tools_photo_canvas_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { editing_tools_value_photo_canvas_init, editing_tools_value_photo_canvas_free_value, editing_tools_value_photo_canvas_copy_value, editing_tools_value_photo_canvas_peek_pointer, "p", editing_tools_value_photo_canvas_collect_value, "p", editing_tools_value_photo_canvas_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsPhotoCanvasClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_photo_canvas_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsPhotoCanvas), 0, (GInstanceInitFunc) editing_tools_photo_canvas_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType editing_tools_photo_canvas_type_id;
	editing_tools_photo_canvas_type_id = g_type_register_fundamental (g_type_fundamental_next (), "EditingToolsPhotoCanvas", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
	EditingToolsPhotoCanvas_private_offset = g_type_add_instance_private (editing_tools_photo_canvas_type_id, sizeof (EditingToolsPhotoCanvasPrivate));
	return editing_tools_photo_canvas_type_id;
}

GType
editing_tools_photo_canvas_get_type (void)
{
	static volatile gsize editing_tools_photo_canvas_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_photo_canvas_type_id__once)) {
		GType editing_tools_photo_canvas_type_id;
		editing_tools_photo_canvas_type_id = editing_tools_photo_canvas_get_type_once ();
		g_once_init_leave (&editing_tools_photo_canvas_type_id__once, editing_tools_photo_canvas_type_id);
	}
	return editing_tools_photo_canvas_type_id__once;
}

gpointer
editing_tools_photo_canvas_ref (gpointer instance)
{
	EditingToolsPhotoCanvas * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
editing_tools_photo_canvas_unref (gpointer instance)
{
	EditingToolsPhotoCanvas * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		EDITING_TOOLS_PHOTO_CANVAS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
editing_tools_editing_tool_get_instance_private (EditingToolsEditingTool* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsEditingTool_private_offset);
}

EditingToolsEditingTool*
editing_tools_editing_tool_construct (GType object_type,
                                      const gchar* name)
{
	EditingToolsEditingTool* self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (name != NULL, NULL);
	self = (EditingToolsEditingTool*) g_type_create_instance (object_type);
	_tmp0_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	return self;
}

static gpointer
_editing_tools_photo_canvas_ref0 (gpointer self)
{
	return self ? editing_tools_photo_canvas_ref (self) : NULL;
}

static gboolean
_editing_tools_editing_tool_on_keypress_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                    GdkEventKey* event,
                                                                    gpointer self)
{
	gboolean result;
	result = editing_tools_editing_tool_on_keypress ((EditingToolsEditingTool*) self, event);
	return result;
}

static void
editing_tools_editing_tool_real_activate (EditingToolsEditingTool* self,
                                          EditingToolsPhotoCanvas* canvas)
{
	EditingToolsPhotoCanvas* _tmp0_;
	EditingToolsEditingToolWindow* _tmp1_;
	EditingToolsPhotoCanvas* _tmp2_;
	EditingToolsEditingToolWindow* _tmp3_;
	EditingToolsEditingToolWindow* _tmp4_;
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	_tmp0_ = self->canvas;
	_vala_assert (_tmp0_ == NULL, "this.canvas == null");
	_tmp1_ = self->priv->tool_window;
	_vala_assert (_tmp1_ == NULL, "tool_window == null");
	_tmp2_ = _editing_tools_photo_canvas_ref0 (canvas);
	_editing_tools_photo_canvas_unref0 (self->canvas);
	self->canvas = _tmp2_;
	_tmp3_ = editing_tools_editing_tool_get_tool_window (self);
	_g_object_unref0 (self->priv->tool_window);
	self->priv->tool_window = _tmp3_;
	_tmp4_ = self->priv->tool_window;
	if (_tmp4_ != NULL) {
		EditingToolsEditingToolWindow* _tmp5_;
		_tmp5_ = self->priv->tool_window;
		g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_widget_get_type (), GtkWidget), "key-press-event", (GCallback) _editing_tools_editing_tool_on_keypress_gtk_widget_key_press_event, self);
	}
	g_signal_emit (self, editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_ACTIVATED_SIGNAL], 0);
}

void
editing_tools_editing_tool_activate (EditingToolsEditingTool* self,
                                     EditingToolsPhotoCanvas* canvas)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self));
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->activate) {
		_klass_->activate (self, canvas);
	}
}

static void
editing_tools_editing_tool_real_deactivate (EditingToolsEditingTool* self)
{
	gboolean _tmp0_ = FALSE;
	EditingToolsPhotoCanvas* _tmp1_;
	EditingToolsEditingToolWindow* _tmp3_;
	_tmp1_ = self->canvas;
	if (_tmp1_ == NULL) {
		EditingToolsEditingToolWindow* _tmp2_;
		_tmp2_ = self->priv->tool_window;
		_tmp0_ = _tmp2_ == NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	_editing_tools_photo_canvas_unref0 (self->canvas);
	self->canvas = NULL;
	_tmp3_ = self->priv->tool_window;
	if (_tmp3_ != NULL) {
		EditingToolsEditingToolWindow* _tmp4_;
		guint _tmp5_;
		_tmp4_ = self->priv->tool_window;
		g_signal_parse_name ("key-press-event", gtk_widget_get_type (), &_tmp5_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _editing_tools_editing_tool_on_keypress_gtk_widget_key_press_event, self);
		_g_object_unref0 (self->priv->tool_window);
		self->priv->tool_window = NULL;
	}
	g_signal_emit (self, editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_DEACTIVATED_SIGNAL], 0);
}

void
editing_tools_editing_tool_deactivate (EditingToolsEditingTool* self)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self));
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->deactivate) {
		_klass_->deactivate (self);
	}
}

gboolean
editing_tools_editing_tool_is_activated (EditingToolsEditingTool* self)
{
	EditingToolsPhotoCanvas* _tmp0_;
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self), FALSE);
	_tmp0_ = self->canvas;
	result = _tmp0_ != NULL;
	return result;
}

static EditingToolsEditingToolWindow*
editing_tools_editing_tool_real_get_tool_window (EditingToolsEditingTool* self)
{
	EditingToolsEditingToolWindow* result;
	result = NULL;
	return result;
}

EditingToolsEditingToolWindow*
editing_tools_editing_tool_get_tool_window (EditingToolsEditingTool* self)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_val_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self), NULL);
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->get_tool_window) {
		return _klass_->get_tool_window (self);
	}
	return NULL;
}

static GdkPixbuf*
editing_tools_editing_tool_real_get_display_pixbuf (EditingToolsEditingTool* self,
                                                    Scaling* scaling,
                                                    Photo* photo,
                                                    Dimensions* max_dim,
                                                    GError** error)
{
	Dimensions _vala_max_dim = {0};
	GdkPixbuf* result;
	g_return_val_if_fail (scaling != NULL, NULL);
	g_return_val_if_fail (IS_PHOTO (photo), NULL);
	dimensions_init (&_vala_max_dim, 0, 0);
	result = NULL;
	if (max_dim) {
		*max_dim = _vala_max_dim;
	}
	return result;
}

GdkPixbuf*
editing_tools_editing_tool_get_display_pixbuf (EditingToolsEditingTool* self,
                                               Scaling* scaling,
                                               Photo* photo,
                                               Dimensions* max_dim,
                                               GError** error)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_val_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self), NULL);
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->get_display_pixbuf) {
		return _klass_->get_display_pixbuf (self, scaling, photo, max_dim, error);
	}
	return NULL;
}

static void
editing_tools_editing_tool_real_on_left_click (EditingToolsEditingTool* self,
                                               gint x,
                                               gint y)
{
}

void
editing_tools_editing_tool_on_left_click (EditingToolsEditingTool* self,
                                          gint x,
                                          gint y)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self));
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->on_left_click) {
		_klass_->on_left_click (self, x, y);
	}
}

static void
editing_tools_editing_tool_real_on_left_released (EditingToolsEditingTool* self,
                                                  gint x,
                                                  gint y)
{
}

void
editing_tools_editing_tool_on_left_released (EditingToolsEditingTool* self,
                                             gint x,
                                             gint y)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self));
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->on_left_released) {
		_klass_->on_left_released (self, x, y);
	}
}

static void
editing_tools_editing_tool_real_on_motion (EditingToolsEditingTool* self,
                                           gint x,
                                           gint y,
                                           GdkModifierType mask)
{
}

void
editing_tools_editing_tool_on_motion (EditingToolsEditingTool* self,
                                      gint x,
                                      gint y,
                                      GdkModifierType mask)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self));
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->on_motion) {
		_klass_->on_motion (self, x, y, mask);
	}
}

static gboolean
editing_tools_editing_tool_real_on_leave_notify_event (EditingToolsEditingTool* self)
{
	gboolean result;
	result = FALSE;
	return result;
}

gboolean
editing_tools_editing_tool_on_leave_notify_event (EditingToolsEditingTool* self)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_val_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self), FALSE);
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->on_leave_notify_event) {
		return _klass_->on_leave_notify_event (self);
	}
	return FALSE;
}

static gboolean
editing_tools_editing_tool_real_on_keypress (EditingToolsEditingTool* self,
                                             GdkEventKey* event)
{
	const gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = gdk_keyval_name (event->keyval);
	if (g_strcmp0 (_tmp0_, "Escape") == 0) {
		editing_tools_editing_tool_notify_cancel (self);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

gboolean
editing_tools_editing_tool_on_keypress (EditingToolsEditingTool* self,
                                        GdkEventKey* event)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_val_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self), FALSE);
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->on_keypress) {
		return _klass_->on_keypress (self, event);
	}
	return FALSE;
}

static void
editing_tools_editing_tool_real_paint (EditingToolsEditingTool* self,
                                       cairo_t* ctx)
{
	g_return_if_fail (ctx != NULL);
}

void
editing_tools_editing_tool_paint (EditingToolsEditingTool* self,
                                  cairo_t* ctx)
{
	EditingToolsEditingToolClass* _klass_;
	g_return_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self));
	_klass_ = EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self);
	if (_klass_->paint) {
		_klass_->paint (self, ctx);
	}
}

void
editing_tools_editing_tool_notify_cancel (EditingToolsEditingTool* self)
{
	g_return_if_fail (EDITING_TOOLS_IS_EDITING_TOOL (self));
	g_signal_emit (self, editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_CANCELLED_SIGNAL], 0);
}

static void
g_cclosure_user_marshal_VOID__OBJECT_OBJECT_BOXED_BOOLEAN (GClosure * closure,
                                                           GValue * return_value,
                                                           guint n_param_values,
                                                           const GValue * param_values,
                                                           gpointer invocation_hint,
                                                           gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT_BOXED_BOOLEAN) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer arg_3, gboolean arg_4, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_OBJECT_BOXED_BOOLEAN callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 5);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_OBJECT_BOXED_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_object (param_values + 2), g_value_get_boxed (param_values + 3), g_value_get_boolean (param_values + 4), data2);
}

static void
editing_tools_value_editing_tool_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
editing_tools_value_editing_tool_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		editing_tools_editing_tool_unref (value->data[0].v_pointer);
	}
}

static void
editing_tools_value_editing_tool_copy_value (const GValue* src_value,
                                             GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = editing_tools_editing_tool_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
editing_tools_value_editing_tool_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
editing_tools_value_editing_tool_collect_value (GValue* value,
                                                guint n_collect_values,
                                                GTypeCValue* collect_values,
                                                guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		EditingToolsEditingTool * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = editing_tools_editing_tool_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
editing_tools_value_editing_tool_lcopy_value (const GValue* value,
                                              guint n_collect_values,
                                              GTypeCValue* collect_values,
                                              guint collect_flags)
{
	EditingToolsEditingTool ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = editing_tools_editing_tool_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
editing_tools_param_spec_editing_tool (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags)
{
	EditingToolsParamSpecEditingTool* spec;
	g_return_val_if_fail (g_type_is_a (object_type, EDITING_TOOLS_TYPE_EDITING_TOOL), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
editing_tools_value_get_editing_tool (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EDITING_TOOLS_TYPE_EDITING_TOOL), NULL);
	return value->data[0].v_pointer;
}

void
editing_tools_value_set_editing_tool (GValue* value,
                                      gpointer v_object)
{
	EditingToolsEditingTool * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EDITING_TOOLS_TYPE_EDITING_TOOL));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EDITING_TOOLS_TYPE_EDITING_TOOL));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		editing_tools_editing_tool_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		editing_tools_editing_tool_unref (old);
	}
}

void
editing_tools_value_take_editing_tool (GValue* value,
                                       gpointer v_object)
{
	EditingToolsEditingTool * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EDITING_TOOLS_TYPE_EDITING_TOOL));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EDITING_TOOLS_TYPE_EDITING_TOOL));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		editing_tools_editing_tool_unref (old);
	}
}

static void
editing_tools_editing_tool_class_init (EditingToolsEditingToolClass * klass,
                                       gpointer klass_data)
{
	editing_tools_editing_tool_parent_class = g_type_class_peek_parent (klass);
	((EditingToolsEditingToolClass *) klass)->finalize = editing_tools_editing_tool_finalize;
	g_type_class_adjust_private_offset (klass, &EditingToolsEditingTool_private_offset);
	((EditingToolsEditingToolClass *) klass)->activate = (void (*) (EditingToolsEditingTool*, EditingToolsPhotoCanvas*)) editing_tools_editing_tool_real_activate;
	((EditingToolsEditingToolClass *) klass)->deactivate = (void (*) (EditingToolsEditingTool*)) editing_tools_editing_tool_real_deactivate;
	((EditingToolsEditingToolClass *) klass)->get_tool_window = (EditingToolsEditingToolWindow* (*) (EditingToolsEditingTool*)) editing_tools_editing_tool_real_get_tool_window;
	((EditingToolsEditingToolClass *) klass)->get_display_pixbuf = (GdkPixbuf* (*) (EditingToolsEditingTool*, Scaling*, Photo*, Dimensions*, GError**)) editing_tools_editing_tool_real_get_display_pixbuf;
	((EditingToolsEditingToolClass *) klass)->on_left_click = (void (*) (EditingToolsEditingTool*, gint, gint)) editing_tools_editing_tool_real_on_left_click;
	((EditingToolsEditingToolClass *) klass)->on_left_released = (void (*) (EditingToolsEditingTool*, gint, gint)) editing_tools_editing_tool_real_on_left_released;
	((EditingToolsEditingToolClass *) klass)->on_motion = (void (*) (EditingToolsEditingTool*, gint, gint, GdkModifierType)) editing_tools_editing_tool_real_on_motion;
	((EditingToolsEditingToolClass *) klass)->on_leave_notify_event = (gboolean (*) (EditingToolsEditingTool*)) editing_tools_editing_tool_real_on_leave_notify_event;
	((EditingToolsEditingToolClass *) klass)->on_keypress = (gboolean (*) (EditingToolsEditingTool*, GdkEventKey*)) editing_tools_editing_tool_real_on_keypress;
	((EditingToolsEditingToolClass *) klass)->paint = (void (*) (EditingToolsEditingTool*, cairo_t*)) editing_tools_editing_tool_real_paint;
	editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_ACTIVATED_SIGNAL] = g_signal_new ("activated", EDITING_TOOLS_TYPE_EDITING_TOOL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_DEACTIVATED_SIGNAL] = g_signal_new ("deactivated", EDITING_TOOLS_TYPE_EDITING_TOOL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_APPLIED_SIGNAL] = g_signal_new ("applied", EDITING_TOOLS_TYPE_EDITING_TOOL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT_BOXED_BOOLEAN, G_TYPE_NONE, 4, TYPE_COMMAND, gdk_pixbuf_get_type (), TYPE_DIMENSIONS, G_TYPE_BOOLEAN);
	editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_CANCELLED_SIGNAL] = g_signal_new ("cancelled", EDITING_TOOLS_TYPE_EDITING_TOOL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_ABORTED_SIGNAL] = g_signal_new ("aborted", EDITING_TOOLS_TYPE_EDITING_TOOL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
editing_tools_editing_tool_instance_init (EditingToolsEditingTool * self,
                                          gpointer klass)
{
	self->priv = editing_tools_editing_tool_get_instance_private (self);
	self->canvas = NULL;
	self->priv->tool_window = NULL;
	self->ref_count = 1;
}

static void
editing_tools_editing_tool_finalize (EditingToolsEditingTool * obj)
{
	EditingToolsEditingTool * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool);
	g_signal_handlers_destroy (self);
	_editing_tools_photo_canvas_unref0 (self->canvas);
	_g_object_unref0 (self->priv->tool_window);
	_cairo_surface_destroy0 (self->surface);
	_g_free0 (self->name);
}

static GType
editing_tools_editing_tool_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { editing_tools_value_editing_tool_init, editing_tools_value_editing_tool_free_value, editing_tools_value_editing_tool_copy_value, editing_tools_value_editing_tool_peek_pointer, "p", editing_tools_value_editing_tool_collect_value, "p", editing_tools_value_editing_tool_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsEditingToolClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_editing_tool_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsEditingTool), 0, (GInstanceInitFunc) editing_tools_editing_tool_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType editing_tools_editing_tool_type_id;
	editing_tools_editing_tool_type_id = g_type_register_fundamental (g_type_fundamental_next (), "EditingToolsEditingTool", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
	EditingToolsEditingTool_private_offset = g_type_add_instance_private (editing_tools_editing_tool_type_id, sizeof (EditingToolsEditingToolPrivate));
	return editing_tools_editing_tool_type_id;
}

GType
editing_tools_editing_tool_get_type (void)
{
	static volatile gsize editing_tools_editing_tool_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_editing_tool_type_id__once)) {
		GType editing_tools_editing_tool_type_id;
		editing_tools_editing_tool_type_id = editing_tools_editing_tool_get_type_once ();
		g_once_init_leave (&editing_tools_editing_tool_type_id__once, editing_tools_editing_tool_type_id);
	}
	return editing_tools_editing_tool_type_id__once;
}

gpointer
editing_tools_editing_tool_ref (gpointer instance)
{
	EditingToolsEditingTool * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
editing_tools_editing_tool_unref (gpointer instance)
{
	EditingToolsEditingTool * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		EDITING_TOOLS_EDITING_TOOL_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
editing_tools_crop_tool_get_instance_private (EditingToolsCropTool* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsCropTool_private_offset);
}

static EditingToolsCropToolReticleOrientation
editing_tools_crop_tool_reticle_orientation_toggle (EditingToolsCropToolReticleOrientation self)
{
	EditingToolsCropToolReticleOrientation _tmp0_ = 0;
	EditingToolsCropToolReticleOrientation result;
	if (self == EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_LANDSCAPE) {
		_tmp0_ = EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_PORTRAIT;
	} else {
		_tmp0_ = EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_LANDSCAPE;
	}
	result = _tmp0_;
	return result;
}

static GType
editing_tools_crop_tool_reticle_orientation_get_type_once (void)
{
	static const GEnumValue values[] = {{EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_LANDSCAPE, "EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_LANDSCAPE", "landscape"}, {EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_PORTRAIT, "EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_PORTRAIT", "portrait"}, {0, NULL, NULL}};
	GType editing_tools_crop_tool_reticle_orientation_type_id;
	editing_tools_crop_tool_reticle_orientation_type_id = g_enum_register_static ("EditingToolsCropToolReticleOrientation", values);
	return editing_tools_crop_tool_reticle_orientation_type_id;
}

static GType
editing_tools_crop_tool_reticle_orientation_get_type (void)
{
	static volatile gsize editing_tools_crop_tool_reticle_orientation_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_crop_tool_reticle_orientation_type_id__once)) {
		GType editing_tools_crop_tool_reticle_orientation_type_id;
		editing_tools_crop_tool_reticle_orientation_type_id = editing_tools_crop_tool_reticle_orientation_get_type_once ();
		g_once_init_leave (&editing_tools_crop_tool_reticle_orientation_type_id__once, editing_tools_crop_tool_reticle_orientation_type_id);
	}
	return editing_tools_crop_tool_reticle_orientation_type_id__once;
}

static GType
editing_tools_crop_tool_constraint_mode_get_type_once (void)
{
	static const GEnumValue values[] = {{EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_NORMAL, "EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_NORMAL", "normal"}, {EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_CUSTOM, "EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_CUSTOM", "custom"}, {0, NULL, NULL}};
	GType editing_tools_crop_tool_constraint_mode_type_id;
	editing_tools_crop_tool_constraint_mode_type_id = g_enum_register_static ("EditingToolsCropToolConstraintMode", values);
	return editing_tools_crop_tool_constraint_mode_type_id;
}

static GType
editing_tools_crop_tool_constraint_mode_get_type (void)
{
	static volatile gsize editing_tools_crop_tool_constraint_mode_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_crop_tool_constraint_mode_type_id__once)) {
		GType editing_tools_crop_tool_constraint_mode_type_id;
		editing_tools_crop_tool_constraint_mode_type_id = editing_tools_crop_tool_constraint_mode_get_type_once ();
		g_once_init_leave (&editing_tools_crop_tool_constraint_mode_type_id__once, editing_tools_crop_tool_constraint_mode_type_id);
	}
	return editing_tools_crop_tool_constraint_mode_type_id__once;
}

static EditingToolsCropTool*
editing_tools_crop_tool_construct (GType object_type)
{
	EditingToolsCropTool* self = NULL;
	self = (EditingToolsCropTool*) editing_tools_editing_tool_construct (object_type, "CropTool");
	return self;
}

static EditingToolsCropTool*
editing_tools_crop_tool_new (void)
{
	return editing_tools_crop_tool_construct (EDITING_TOOLS_TYPE_CROP_TOOL);
}

EditingToolsCropTool*
editing_tools_crop_tool_factory (void)
{
	EditingToolsCropTool* _tmp0_;
	EditingToolsCropTool* result;
	_tmp0_ = editing_tools_crop_tool_new ();
	result = _tmp0_;
	return result;
}

gboolean
editing_tools_crop_tool_is_available (Photo* photo,
                                      Scaling* scaling)
{
	Dimensions dim = {0};
	Dimensions _tmp0_ = {0};
	Dimensions _tmp1_ = {0};
	gboolean _tmp2_ = FALSE;
	Dimensions _tmp3_;
	gboolean result;
	g_return_val_if_fail (IS_PHOTO (photo), FALSE);
	g_return_val_if_fail (scaling != NULL, FALSE);
	photo_get_original_dimensions (photo, &_tmp0_);
	scaling_get_scaled_dimensions (scaling, &_tmp0_, &_tmp1_);
	dim = _tmp1_;
	_tmp3_ = dim;
	if (_tmp3_.width > EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE) {
		Dimensions _tmp4_;
		_tmp4_ = dim;
		_tmp2_ = _tmp4_.height > EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE;
	} else {
		_tmp2_ = FALSE;
	}
	result = _tmp2_;
	return result;
}

static void
_vala_array_add5 (EditingToolsCropToolConstraintDescription** * array,
                  gint* length,
                  gint* size,
                  EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add6 (EditingToolsCropToolConstraintDescription** * array,
                  gint* length,
                  gint* size,
                  EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add7 (EditingToolsCropToolConstraintDescription** * array,
                  gint* length,
                  gint* size,
                  EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add8 (EditingToolsCropToolConstraintDescription** * array,
                  gint* length,
                  gint* size,
                  EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add9 (EditingToolsCropToolConstraintDescription** * array,
                  gint* length,
                  gint* size,
                  EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add10 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add11 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add12 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add13 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add14 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add15 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add16 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add17 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add18 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add19 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add20 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add21 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add22 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add23 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add24 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add25 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add26 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add27 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add28 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add29 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add30 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add31 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add32 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add33 (EditingToolsCropToolConstraintDescription** * array,
                   gint* length,
                   gint* size,
                   EditingToolsCropToolConstraintDescription* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (EditingToolsCropToolConstraintDescription*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static EditingToolsCropToolConstraintDescription**
editing_tools_crop_tool_create_constraints (gint* result_length1)
{
	EditingToolsCropToolConstraintDescription** _result_ = NULL;
	EditingToolsCropToolConstraintDescription** _tmp0_;
	gint _result__length1;
	gint __result__size_;
	EditingToolsCropToolConstraintDescription* _tmp1_;
	EditingToolsCropToolConstraintDescription* _tmp2_;
	EditingToolsCropToolConstraintDescription* _tmp3_;
	EditingToolsCropToolConstraintDescription* _tmp4_;
	EditingToolsCropToolConstraintDescription* _tmp5_;
	EditingToolsCropToolConstraintDescription* _tmp6_;
	EditingToolsCropToolConstraintDescription* _tmp7_;
	EditingToolsCropToolConstraintDescription* _tmp8_;
	EditingToolsCropToolConstraintDescription* _tmp9_;
	EditingToolsCropToolConstraintDescription* _tmp10_;
	EditingToolsCropToolConstraintDescription* _tmp11_;
	EditingToolsCropToolConstraintDescription* _tmp12_;
	EditingToolsCropToolConstraintDescription* _tmp13_;
	EditingToolsCropToolConstraintDescription* _tmp14_;
	EditingToolsCropToolConstraintDescription* _tmp15_;
	EditingToolsCropToolConstraintDescription* _tmp16_;
	EditingToolsCropToolConstraintDescription* _tmp17_;
	EditingToolsCropToolConstraintDescription* _tmp18_;
	EditingToolsCropToolConstraintDescription* _tmp19_;
	EditingToolsCropToolConstraintDescription* _tmp20_;
	EditingToolsCropToolConstraintDescription* _tmp21_;
	EditingToolsCropToolConstraintDescription* _tmp22_;
	EditingToolsCropToolConstraintDescription* _tmp23_;
	EditingToolsCropToolConstraintDescription* _tmp24_;
	EditingToolsCropToolConstraintDescription* _tmp25_;
	EditingToolsCropToolConstraintDescription* _tmp26_;
	EditingToolsCropToolConstraintDescription* _tmp27_;
	EditingToolsCropToolConstraintDescription* _tmp28_;
	EditingToolsCropToolConstraintDescription* _tmp29_;
	EditingToolsCropToolConstraintDescription** _tmp30_;
	gint _tmp30__length1;
	EditingToolsCropToolConstraintDescription** result;
	_tmp0_ = g_new0 (EditingToolsCropToolConstraintDescription*, 0 + 1);
	_result_ = _tmp0_;
	_result__length1 = 0;
	__result__size_ = _result__length1;
	_tmp1_ = editing_tools_crop_tool_constraint_description_new (_ ("Unconstrained"), 0, 0, FALSE, EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO);
	_vala_array_add5 (&_result_, &_result__length1, &__result__size_, _tmp1_);
	_tmp2_ = editing_tools_crop_tool_constraint_description_new (_ ("Square"), 1, 1, FALSE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add6 (&_result_, &_result__length1, &__result__size_, _tmp2_);
	_tmp3_ = editing_tools_crop_tool_constraint_description_new (_ ("Screen"), 0, 0, TRUE, EDITING_TOOLS_CROP_TOOL_SCREEN_ASPECT_RATIO);
	_vala_array_add7 (&_result_, &_result__length1, &__result__size_, _tmp3_);
	_tmp4_ = editing_tools_crop_tool_constraint_description_new (_ ("Original Size"), 0, 0, TRUE, EDITING_TOOLS_CROP_TOOL_ORIGINAL_ASPECT_RATIO);
	_vala_array_add8 (&_result_, &_result__length1, &__result__size_, _tmp4_);
	_tmp5_ = editing_tools_crop_tool_constraint_description_new (_ ("-"), 0, 0, FALSE, EDITING_TOOLS_CROP_TOOL_SEPARATOR);
	_vala_array_add9 (&_result_, &_result__length1, &__result__size_, _tmp5_);
	_tmp6_ = editing_tools_crop_tool_constraint_description_new (_ ("SD Video (4 ∶ 3)"), 4, 3, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add10 (&_result_, &_result__length1, &__result__size_, _tmp6_);
	_tmp7_ = editing_tools_crop_tool_constraint_description_new (_ ("HD Video (16 ∶ 9)"), 16, 9, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add11 (&_result_, &_result__length1, &__result__size_, _tmp7_);
	_tmp8_ = editing_tools_crop_tool_constraint_description_new (_ ("-"), 0, 0, FALSE, EDITING_TOOLS_CROP_TOOL_SEPARATOR);
	_vala_array_add12 (&_result_, &_result__length1, &__result__size_, _tmp8_);
	_tmp9_ = editing_tools_crop_tool_constraint_description_new (_ ("Wallet (2 × 3 in.)"), 3, 2, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add13 (&_result_, &_result__length1, &__result__size_, _tmp9_);
	_tmp10_ = editing_tools_crop_tool_constraint_description_new (_ ("Notecard (3 × 5 in.)"), 5, 3, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add14 (&_result_, &_result__length1, &__result__size_, _tmp10_);
	_tmp11_ = editing_tools_crop_tool_constraint_description_new (_ ("4 × 6 in."), 6, 4, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add15 (&_result_, &_result__length1, &__result__size_, _tmp11_);
	_tmp12_ = editing_tools_crop_tool_constraint_description_new (_ ("5 × 7 in."), 7, 5, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add16 (&_result_, &_result__length1, &__result__size_, _tmp12_);
	_tmp13_ = editing_tools_crop_tool_constraint_description_new (_ ("8 × 10 in."), 10, 8, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add17 (&_result_, &_result__length1, &__result__size_, _tmp13_);
	_tmp14_ = editing_tools_crop_tool_constraint_description_new (_ ("Letter (8.5 × 11 in.)"), 85, 110, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add18 (&_result_, &_result__length1, &__result__size_, _tmp14_);
	_tmp15_ = editing_tools_crop_tool_constraint_description_new (_ ("11 × 14 in."), 14, 11, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add19 (&_result_, &_result__length1, &__result__size_, _tmp15_);
	_tmp16_ = editing_tools_crop_tool_constraint_description_new (_ ("Tabloid (11 × 17 in.)"), 17, 11, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add20 (&_result_, &_result__length1, &__result__size_, _tmp16_);
	_tmp17_ = editing_tools_crop_tool_constraint_description_new (_ ("16 × 20 in."), 20, 16, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add21 (&_result_, &_result__length1, &__result__size_, _tmp17_);
	_tmp18_ = editing_tools_crop_tool_constraint_description_new (_ ("-"), 0, 0, FALSE, EDITING_TOOLS_CROP_TOOL_SEPARATOR);
	_vala_array_add22 (&_result_, &_result__length1, &__result__size_, _tmp18_);
	_tmp19_ = editing_tools_crop_tool_constraint_description_new (_ ("Metric Wallet (9 × 13 cm)"), 13, 9, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add23 (&_result_, &_result__length1, &__result__size_, _tmp19_);
	_tmp20_ = editing_tools_crop_tool_constraint_description_new (_ ("Postcard (10 × 15 cm)"), 15, 10, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add24 (&_result_, &_result__length1, &__result__size_, _tmp20_);
	_tmp21_ = editing_tools_crop_tool_constraint_description_new (_ ("13 × 18 cm"), 18, 13, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add25 (&_result_, &_result__length1, &__result__size_, _tmp21_);
	_tmp22_ = editing_tools_crop_tool_constraint_description_new (_ ("18 × 24 cm"), 24, 18, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add26 (&_result_, &_result__length1, &__result__size_, _tmp22_);
	_tmp23_ = editing_tools_crop_tool_constraint_description_new (_ ("A4 (210 × 297 mm)"), 210, 297, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add27 (&_result_, &_result__length1, &__result__size_, _tmp23_);
	_tmp24_ = editing_tools_crop_tool_constraint_description_new (_ ("20 × 30 cm"), 30, 20, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add28 (&_result_, &_result__length1, &__result__size_, _tmp24_);
	_tmp25_ = editing_tools_crop_tool_constraint_description_new (_ ("24 × 40 cm"), 40, 24, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add29 (&_result_, &_result__length1, &__result__size_, _tmp25_);
	_tmp26_ = editing_tools_crop_tool_constraint_description_new (_ ("30 × 40 cm"), 40, 30, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add30 (&_result_, &_result__length1, &__result__size_, _tmp26_);
	_tmp27_ = editing_tools_crop_tool_constraint_description_new (_ ("A3 (297 × 420 mm)"), 420, 297, TRUE, EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS);
	_vala_array_add31 (&_result_, &_result__length1, &__result__size_, _tmp27_);
	_tmp28_ = editing_tools_crop_tool_constraint_description_new (_ ("-"), 0, 0, FALSE, EDITING_TOOLS_CROP_TOOL_SEPARATOR);
	_vala_array_add32 (&_result_, &_result__length1, &__result__size_, _tmp28_);
	_tmp29_ = editing_tools_crop_tool_constraint_description_new (_ ("Custom"), 0, 0, TRUE, EDITING_TOOLS_CROP_TOOL_CUSTOM_ASPECT_RATIO);
	_vala_array_add33 (&_result_, &_result__length1, &__result__size_, _tmp29_);
	_tmp30_ = _result_;
	_tmp30__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp30__length1;
	}
	result = _tmp30_;
	return result;
}

static gpointer
_editing_tools_crop_tool_constraint_description_ref0 (gpointer self)
{
	return self ? editing_tools_crop_tool_constraint_description_ref (self) : NULL;
}

static GtkListStore*
editing_tools_crop_tool_create_constraint_list (EditingToolsCropToolConstraintDescription** constraint_data,
                                                gint constraint_data_length1)
{
	GtkListStore* _result_ = NULL;
	GtkListStore* _tmp0_;
	GtkTreeIter iter = {0};
	GtkListStore* result;
	_tmp0_ = gtk_list_store_new (1, G_TYPE_STRING, G_TYPE_STRING, -1);
	_result_ = _tmp0_;
	{
		EditingToolsCropToolConstraintDescription** constraint_collection = NULL;
		gint constraint_collection_length1 = 0;
		gint _constraint_collection_size_ = 0;
		gint constraint_it = 0;
		constraint_collection = constraint_data;
		constraint_collection_length1 = constraint_data_length1;
		for (constraint_it = 0; constraint_it < constraint_collection_length1; constraint_it = constraint_it + 1) {
			EditingToolsCropToolConstraintDescription* _tmp1_;
			EditingToolsCropToolConstraintDescription* constraint = NULL;
			_tmp1_ = _editing_tools_crop_tool_constraint_description_ref0 (constraint_collection[constraint_it]);
			constraint = _tmp1_;
			{
				GtkListStore* _tmp2_;
				GtkTreeIter _tmp3_ = {0};
				GtkListStore* _tmp4_;
				GtkTreeIter _tmp5_;
				EditingToolsCropToolConstraintDescription* _tmp6_;
				const gchar* _tmp7_;
				GValue _tmp8_ = {0};
				_tmp2_ = _result_;
				gtk_list_store_append (_tmp2_, &_tmp3_);
				iter = _tmp3_;
				_tmp4_ = _result_;
				_tmp5_ = iter;
				_tmp6_ = constraint;
				_tmp7_ = _tmp6_->name;
				g_value_init (&_tmp8_, G_TYPE_STRING);
				g_value_set_string (&_tmp8_, _tmp7_);
				gtk_list_store_set_value (_tmp4_, &_tmp5_, 0, &_tmp8_);
				G_IS_VALUE (&_tmp8_) ? (g_value_unset (&_tmp8_), NULL) : NULL;
				_editing_tools_crop_tool_constraint_description_unref0 (constraint);
			}
		}
	}
	result = _result_;
	return result;
}

static void
editing_tools_crop_tool_update_pivot_button_state (EditingToolsCropTool* self)
{
	EditingToolsCropToolCropToolWindow* _tmp0_;
	GtkButton* _tmp1_;
	EditingToolsCropToolConstraintDescription* _tmp2_;
	EditingToolsCropToolConstraintDescription* _tmp3_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	_tmp0_ = self->priv->crop_tool_window;
	_tmp1_ = _tmp0_->pivot_reticle_button;
	_tmp2_ = editing_tools_crop_tool_get_selected_constraint (self);
	_tmp3_ = _tmp2_;
	gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget), _tmp3_->is_pivotable);
	_editing_tools_crop_tool_constraint_description_unref0 (_tmp3_);
}

static EditingToolsCropToolConstraintDescription*
editing_tools_crop_tool_get_selected_constraint (EditingToolsCropTool* self)
{
	EditingToolsCropToolConstraintDescription* _result_ = NULL;
	EditingToolsCropToolConstraintDescription** _tmp0_;
	gint _tmp0__length1;
	EditingToolsCropToolCropToolWindow* _tmp1_;
	GtkComboBox* _tmp2_;
	EditingToolsCropToolConstraintDescription* _tmp3_;
	EditingToolsCropToolConstraintDescription* _tmp4_;
	EditingToolsCropToolConstraintDescription* _tmp5_;
	EditingToolsCropToolConstraintDescription* result;
	g_return_val_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self), NULL);
	_tmp0_ = self->priv->constraints;
	_tmp0__length1 = self->priv->constraints_length1;
	_tmp1_ = self->priv->crop_tool_window;
	_tmp2_ = _tmp1_->constraint_combo;
	_tmp3_ = _tmp0_[gtk_combo_box_get_active (_tmp2_)];
	_tmp4_ = _editing_tools_crop_tool_constraint_description_ref0 (_tmp3_);
	_result_ = _tmp4_;
	_tmp5_ = _result_;
	if (_tmp5_->aspect_ratio == EDITING_TOOLS_CROP_TOOL_ORIGINAL_ASPECT_RATIO) {
		EditingToolsCropToolConstraintDescription* _tmp6_;
		EditingToolsPhotoCanvas* _tmp7_;
		GdkRectangle _tmp8_ = {0};
		EditingToolsCropToolConstraintDescription* _tmp9_;
		EditingToolsPhotoCanvas* _tmp10_;
		GdkRectangle _tmp11_ = {0};
		_tmp6_ = _result_;
		_tmp7_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp7_, &_tmp8_);
		_tmp6_->basis_width = _tmp8_.width;
		_tmp9_ = _result_;
		_tmp10_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp10_, &_tmp11_);
		_tmp9_->basis_height = _tmp11_.height;
	} else {
		EditingToolsCropToolConstraintDescription* _tmp12_;
		_tmp12_ = _result_;
		if (_tmp12_->aspect_ratio == EDITING_TOOLS_CROP_TOOL_SCREEN_ASPECT_RATIO) {
			Dimensions dim = {0};
			AppWindow* _tmp13_;
			AppWindow* _tmp14_;
			Dimensions _tmp15_ = {0};
			Dimensions _tmp16_;
			EditingToolsCropToolConstraintDescription* _tmp17_;
			Dimensions _tmp18_;
			EditingToolsCropToolConstraintDescription* _tmp19_;
			Dimensions _tmp20_;
			_tmp13_ = app_window_get_instance ();
			_tmp14_ = _tmp13_;
			scaling_get_screen_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_window_get_type (), GtkWindow), &_tmp15_);
			_tmp16_ = _tmp15_;
			_g_object_unref0 (_tmp14_);
			dim = _tmp16_;
			_tmp17_ = _result_;
			_tmp18_ = dim;
			_tmp17_->basis_width = _tmp18_.width;
			_tmp19_ = _result_;
			_tmp20_ = dim;
			_tmp19_->basis_height = _tmp20_.height;
		}
	}
	result = _result_;
	return result;
}

static gboolean
editing_tools_crop_tool_on_width_entry_focus_out (EditingToolsCropTool* self,
                                                  GdkEventFocus* event)
{
	EditingToolsCropToolCropToolWindow* _tmp0_;
	EditingToolsCropToolCropToolWindow* _tmp1_;
	GtkEntry* _tmp2_;
	GtkEntry* _tmp3_;
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self), FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->crop_tool_window;
	_tmp1_ = self->priv->crop_tool_window;
	_tmp2_ = _tmp1_->custom_width_entry;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (_tmp0_->most_recently_edited);
	_tmp0_->most_recently_edited = _tmp3_;
	result = editing_tools_crop_tool_on_custom_entry_focus_out (self, event);
	return result;
}

static gboolean
editing_tools_crop_tool_on_height_entry_focus_out (EditingToolsCropTool* self,
                                                   GdkEventFocus* event)
{
	EditingToolsCropToolCropToolWindow* _tmp0_;
	EditingToolsCropToolCropToolWindow* _tmp1_;
	GtkEntry* _tmp2_;
	GtkEntry* _tmp3_;
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self), FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->crop_tool_window;
	_tmp1_ = self->priv->crop_tool_window;
	_tmp2_ = _tmp1_->custom_height_entry;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (_tmp0_->most_recently_edited);
	_tmp0_->most_recently_edited = _tmp3_;
	result = editing_tools_crop_tool_on_custom_entry_focus_out (self, event);
	return result;
}

static gboolean
editing_tools_crop_tool_on_custom_entry_focus_out (EditingToolsCropTool* self,
                                                   GdkEventFocus* event)
{
	gint width = 0;
	EditingToolsCropToolCropToolWindow* _tmp0_;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint height = 0;
	EditingToolsCropToolCropToolWindow* _tmp4_;
	GtkEntry* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gboolean _tmp16_ = FALSE;
	Box new_crop = {0};
	Box _tmp41_;
	Box _tmp42_ = {0};
	Box _tmp43_;
	Box _tmp44_;
	EditingToolsPhotoCanvas* _tmp45_;
	Box _tmp46_;
	EditingToolsPhotoCanvas* _tmp47_;
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self), FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->crop_tool_window;
	_tmp1_ = _tmp0_->custom_width_entry;
	_tmp2_ = gtk_entry_get_text (_tmp1_);
	_tmp3_ = _tmp2_;
	width = atoi (_tmp3_);
	_tmp4_ = self->priv->crop_tool_window;
	_tmp5_ = _tmp4_->custom_height_entry;
	_tmp6_ = gtk_entry_get_text (_tmp5_);
	_tmp7_ = _tmp6_;
	height = atoi (_tmp7_);
	if (width < 1) {
		EditingToolsCropToolCropToolWindow* _tmp8_;
		GtkEntry* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		width = 1;
		_tmp8_ = self->priv->crop_tool_window;
		_tmp9_ = _tmp8_->custom_width_entry;
		_tmp10_ = g_strdup_printf ("%d", width);
		_tmp11_ = _tmp10_;
		gtk_entry_set_text (_tmp9_, _tmp11_);
		_g_free0 (_tmp11_);
	}
	if (height < 1) {
		EditingToolsCropToolCropToolWindow* _tmp12_;
		GtkEntry* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		height = 1;
		_tmp12_ = self->priv->crop_tool_window;
		_tmp13_ = _tmp12_->custom_height_entry;
		_tmp14_ = g_strdup_printf ("%d", height);
		_tmp15_ = _tmp14_;
		gtk_entry_set_text (_tmp13_, _tmp15_);
		_g_free0 (_tmp15_);
	}
	if (width == self->priv->custom_width) {
		_tmp16_ = height == self->priv->custom_height;
	} else {
		_tmp16_ = FALSE;
	}
	if (_tmp16_) {
		result = FALSE;
		return result;
	}
	self->priv->custom_aspect_ratio = ((gfloat) width) / ((gfloat) height);
	if (self->priv->custom_aspect_ratio < EDITING_TOOLS_CROP_TOOL_MIN_ASPECT_RATIO) {
		EditingToolsCropToolCropToolWindow* _tmp17_;
		GtkEntry* _tmp18_;
		EditingToolsCropToolCropToolWindow* _tmp19_;
		GtkEntry* _tmp20_;
		_tmp17_ = self->priv->crop_tool_window;
		_tmp18_ = _tmp17_->most_recently_edited;
		_tmp19_ = self->priv->crop_tool_window;
		_tmp20_ = _tmp19_->custom_height_entry;
		if (_tmp18_ == _tmp20_) {
			EditingToolsCropToolCropToolWindow* _tmp21_;
			GtkEntry* _tmp22_;
			gchar* _tmp23_;
			gchar* _tmp24_;
			height = (gint) (width / EDITING_TOOLS_CROP_TOOL_MIN_ASPECT_RATIO);
			_tmp21_ = self->priv->crop_tool_window;
			_tmp22_ = _tmp21_->custom_height_entry;
			_tmp23_ = g_strdup_printf ("%d", height);
			_tmp24_ = _tmp23_;
			gtk_entry_set_text (_tmp22_, _tmp24_);
			_g_free0 (_tmp24_);
		} else {
			EditingToolsCropToolCropToolWindow* _tmp25_;
			GtkEntry* _tmp26_;
			gchar* _tmp27_;
			gchar* _tmp28_;
			width = (gint) (height * EDITING_TOOLS_CROP_TOOL_MIN_ASPECT_RATIO);
			_tmp25_ = self->priv->crop_tool_window;
			_tmp26_ = _tmp25_->custom_width_entry;
			_tmp27_ = g_strdup_printf ("%d", width);
			_tmp28_ = _tmp27_;
			gtk_entry_set_text (_tmp26_, _tmp28_);
			_g_free0 (_tmp28_);
		}
	} else {
		if (self->priv->custom_aspect_ratio > EDITING_TOOLS_CROP_TOOL_MAX_ASPECT_RATIO) {
			EditingToolsCropToolCropToolWindow* _tmp29_;
			GtkEntry* _tmp30_;
			EditingToolsCropToolCropToolWindow* _tmp31_;
			GtkEntry* _tmp32_;
			_tmp29_ = self->priv->crop_tool_window;
			_tmp30_ = _tmp29_->most_recently_edited;
			_tmp31_ = self->priv->crop_tool_window;
			_tmp32_ = _tmp31_->custom_height_entry;
			if (_tmp30_ == _tmp32_) {
				EditingToolsCropToolCropToolWindow* _tmp33_;
				GtkEntry* _tmp34_;
				gchar* _tmp35_;
				gchar* _tmp36_;
				height = (gint) (width / EDITING_TOOLS_CROP_TOOL_MAX_ASPECT_RATIO);
				_tmp33_ = self->priv->crop_tool_window;
				_tmp34_ = _tmp33_->custom_height_entry;
				_tmp35_ = g_strdup_printf ("%d", height);
				_tmp36_ = _tmp35_;
				gtk_entry_set_text (_tmp34_, _tmp36_);
				_g_free0 (_tmp36_);
			} else {
				EditingToolsCropToolCropToolWindow* _tmp37_;
				GtkEntry* _tmp38_;
				gchar* _tmp39_;
				gchar* _tmp40_;
				width = (gint) (height * EDITING_TOOLS_CROP_TOOL_MAX_ASPECT_RATIO);
				_tmp37_ = self->priv->crop_tool_window;
				_tmp38_ = _tmp37_->custom_width_entry;
				_tmp39_ = g_strdup_printf ("%d", width);
				_tmp40_ = _tmp39_;
				gtk_entry_set_text (_tmp38_, _tmp40_);
				_g_free0 (_tmp40_);
			}
		}
	}
	self->priv->custom_aspect_ratio = ((gfloat) width) / ((gfloat) height);
	_tmp41_ = self->priv->scaled_crop;
	editing_tools_crop_tool_constrain_crop (self, &_tmp41_, &_tmp42_);
	new_crop = _tmp42_;
	_tmp43_ = new_crop;
	editing_tools_crop_tool_crop_resized (self, &_tmp43_);
	_tmp44_ = new_crop;
	self->priv->scaled_crop = _tmp44_;
	_tmp45_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp46_ = new_crop;
	editing_tools_photo_canvas_invalidate_area (_tmp45_, &_tmp46_);
	_tmp47_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp47_);
	self->priv->custom_width = width;
	self->priv->custom_height = height;
	result = FALSE;
	return result;
}

static void
editing_tools_crop_tool_on_width_insert_text (EditingToolsCropTool* self,
                                              const gchar* text,
                                              gint length,
                                              gint* position)
{
	EditingToolsCropToolCropToolWindow* _tmp0_;
	GtkEntry* _tmp1_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (text != NULL);
	_tmp0_ = self->priv->crop_tool_window;
	_tmp1_ = _tmp0_->custom_width_entry;
	editing_tools_crop_tool_on_entry_insert_text (self, _tmp1_, text, length, position);
}

static void
editing_tools_crop_tool_on_height_insert_text (EditingToolsCropTool* self,
                                               const gchar* text,
                                               gint length,
                                               gint* position)
{
	EditingToolsCropToolCropToolWindow* _tmp0_;
	GtkEntry* _tmp1_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (text != NULL);
	_tmp0_ = self->priv->crop_tool_window;
	_tmp1_ = _tmp0_->custom_height_entry;
	editing_tools_crop_tool_on_entry_insert_text (self, _tmp1_, text, length, position);
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static void
editing_tools_crop_tool_on_entry_insert_text (EditingToolsCropTool* self,
                                              GtkEntry* sender,
                                              const gchar* text,
                                              gint length,
                                              gint* position)
{
	gchar* new_text = NULL;
	gchar* _tmp2_;
	const gchar* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (sender, gtk_entry_get_type ()));
	g_return_if_fail (text != NULL);
	if (self->priv->entry_insert_in_progress) {
		return;
	}
	self->priv->entry_insert_in_progress = TRUE;
	if (length == -1) {
		gint _tmp0_;
		gint _tmp1_;
		_tmp0_ = strlen (text);
		_tmp1_ = _tmp0_;
		length = (gint) _tmp1_;
	}
	_tmp2_ = g_strdup ("");
	new_text = _tmp2_;
	{
		gint ctr = 0;
		ctr = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = ctr;
					ctr = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				if (!(ctr < length)) {
					break;
				}
				if (g_ascii_isdigit (string_get (text, (glong) ctr))) {
					const gchar* _tmp5_;
					gchar* _tmp6_;
					gchar* _tmp7_;
					gchar* _tmp8_;
					_tmp5_ = new_text;
					_tmp6_ = g_strdup_printf ("%c", (gchar) string_get (text, (glong) ctr));
					_tmp7_ = _tmp6_;
					_tmp8_ = g_strconcat (_tmp5_, _tmp7_, NULL);
					_g_free0 (new_text);
					new_text = _tmp8_;
					_g_free0 (_tmp7_);
				}
			}
		}
	}
	_tmp9_ = new_text;
	_tmp10_ = strlen (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_ > 0) {
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		_tmp12_ = new_text;
		_tmp13_ = new_text;
		_tmp14_ = strlen (_tmp13_);
		_tmp15_ = _tmp14_;
		g_signal_emit_by_name (G_TYPE_CHECK_INSTANCE_CAST (sender, gtk_editable_get_type (), GtkEditable), "insert-text", _tmp12_, (gint) _tmp15_, position);
	}
	g_signal_stop_emission_by_name (sender, "insert-text");
	self->priv->entry_insert_in_progress = FALSE;
	_g_free0 (new_text);
}

static gfloat
editing_tools_crop_tool_get_constraint_aspect_ratio (EditingToolsCropTool* self)
{
	gfloat _result_ = 0.0F;
	EditingToolsCropToolConstraintDescription* _tmp0_;
	EditingToolsCropToolConstraintDescription* _tmp1_;
	gfloat _tmp2_;
	gfloat result;
	g_return_val_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self), -1.0F);
	_tmp0_ = editing_tools_crop_tool_get_selected_constraint (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_->aspect_ratio;
	_editing_tools_crop_tool_constraint_description_unref0 (_tmp1_);
	_result_ = _tmp2_;
	if (_result_ == EDITING_TOOLS_CROP_TOOL_ORIGINAL_ASPECT_RATIO) {
		EditingToolsPhotoCanvas* _tmp3_;
		GdkRectangle _tmp4_ = {0};
		EditingToolsPhotoCanvas* _tmp5_;
		GdkRectangle _tmp6_ = {0};
		_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp3_, &_tmp4_);
		_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp5_, &_tmp6_);
		_result_ = ((gfloat) _tmp4_.width) / ((gfloat) _tmp6_.height);
	} else {
		if (_result_ == EDITING_TOOLS_CROP_TOOL_SCREEN_ASPECT_RATIO) {
			Dimensions dim = {0};
			AppWindow* _tmp7_;
			AppWindow* _tmp8_;
			Dimensions _tmp9_ = {0};
			Dimensions _tmp10_;
			Dimensions _tmp11_;
			Dimensions _tmp12_;
			_tmp7_ = app_window_get_instance ();
			_tmp8_ = _tmp7_;
			scaling_get_screen_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_window_get_type (), GtkWindow), &_tmp9_);
			_tmp10_ = _tmp9_;
			_g_object_unref0 (_tmp8_);
			dim = _tmp10_;
			_tmp11_ = dim;
			_tmp12_ = dim;
			_result_ = ((gfloat) _tmp11_.width) / ((gfloat) _tmp12_.height);
		} else {
			if (_result_ == EDITING_TOOLS_CROP_TOOL_CUSTOM_ASPECT_RATIO) {
				_result_ = self->priv->custom_aspect_ratio;
			}
		}
	}
	if (self->priv->reticle_orientation == EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_PORTRAIT) {
		_result_ = 1.0f / _result_;
	}
	result = _result_;
	return result;
}

static gfloat
editing_tools_crop_tool_get_constraint_aspect_ratio_for_constraint (EditingToolsCropTool* self,
                                                                    EditingToolsCropToolConstraintDescription* constraint,
                                                                    Photo* photo)
{
	gfloat _result_ = 0.0F;
	gfloat result;
	g_return_val_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self), -1.0F);
	g_return_val_if_fail (EDITING_TOOLS_CROP_TOOL_IS_CONSTRAINT_DESCRIPTION (constraint), -1.0F);
	g_return_val_if_fail (IS_PHOTO (photo), -1.0F);
	_result_ = constraint->aspect_ratio;
	if (_result_ == EDITING_TOOLS_CROP_TOOL_ORIGINAL_ASPECT_RATIO) {
		Dimensions orig_dim = {0};
		Dimensions _tmp0_ = {0};
		Dimensions _tmp1_;
		Dimensions _tmp2_;
		photo_get_original_dimensions (photo, &_tmp0_);
		orig_dim = _tmp0_;
		_tmp1_ = orig_dim;
		_tmp2_ = orig_dim;
		_result_ = ((gfloat) _tmp1_.width) / ((gfloat) _tmp2_.height);
	} else {
		if (_result_ == EDITING_TOOLS_CROP_TOOL_SCREEN_ASPECT_RATIO) {
			Dimensions dim = {0};
			AppWindow* _tmp3_;
			AppWindow* _tmp4_;
			Dimensions _tmp5_ = {0};
			Dimensions _tmp6_;
			Dimensions _tmp7_;
			Dimensions _tmp8_;
			_tmp3_ = app_window_get_instance ();
			_tmp4_ = _tmp3_;
			scaling_get_screen_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_window_get_type (), GtkWindow), &_tmp5_);
			_tmp6_ = _tmp5_;
			_g_object_unref0 (_tmp4_);
			dim = _tmp6_;
			_tmp7_ = dim;
			_tmp8_ = dim;
			_result_ = ((gfloat) _tmp7_.width) / ((gfloat) _tmp8_.height);
		} else {
			if (_result_ == EDITING_TOOLS_CROP_TOOL_CUSTOM_ASPECT_RATIO) {
				_result_ = self->priv->custom_aspect_ratio;
			}
		}
	}
	if (self->priv->reticle_orientation == EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_PORTRAIT) {
		_result_ = 1.0f / _result_;
	}
	result = _result_;
	return result;
}

static void
editing_tools_crop_tool_constraint_changed (EditingToolsCropTool* self)
{
	EditingToolsCropToolConstraintDescription* selected_constraint = NULL;
	EditingToolsCropToolConstraintDescription* _tmp0_;
	EditingToolsCropToolConstraintDescription* _tmp1_;
	EditingToolsCropToolConstraintDescription* _tmp7_;
	EditingToolsCropToolConstraintDescription* _tmp8_;
	gboolean _tmp9_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	_tmp0_ = editing_tools_crop_tool_get_selected_constraint (self);
	selected_constraint = _tmp0_;
	_tmp1_ = selected_constraint;
	if (_tmp1_->aspect_ratio == EDITING_TOOLS_CROP_TOOL_CUSTOM_ASPECT_RATIO) {
		editing_tools_crop_tool_set_custom_constraint_mode (self);
	} else {
		EditingToolsCropToolConstraintDescription* _tmp2_;
		editing_tools_crop_tool_set_normal_constraint_mode (self);
		_tmp2_ = selected_constraint;
		if (_tmp2_->aspect_ratio != EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
			ConfigFacade* _tmp3_;
			ConfigFacade* _tmp4_;
			ConfigFacade* _tmp5_;
			ConfigFacade* _tmp6_;
			_tmp3_ = config_facade_get_instance ();
			_tmp4_ = _tmp3_;
			self->priv->custom_init_width = configuration_facade_get_last_crop_width (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
			_g_object_unref0 (_tmp4_);
			_tmp5_ = config_facade_get_instance ();
			_tmp6_ = _tmp5_;
			self->priv->custom_init_height = configuration_facade_get_last_crop_height (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
			_g_object_unref0 (_tmp6_);
			self->priv->custom_aspect_ratio = ((gfloat) self->priv->custom_init_width) / ((gfloat) self->priv->custom_init_height);
		}
	}
	editing_tools_crop_tool_update_pivot_button_state (self);
	_tmp7_ = editing_tools_crop_tool_get_selected_constraint (self);
	_tmp8_ = _tmp7_;
	_tmp9_ = !_tmp8_->is_pivotable;
	_editing_tools_crop_tool_constraint_description_unref0 (_tmp8_);
	if (_tmp9_) {
		self->priv->reticle_orientation = EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_LANDSCAPE;
	}
	if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) != self->priv->pre_aspect_ratio) {
		Box new_crop = {0};
		Box _tmp10_;
		Box _tmp11_ = {0};
		Box _tmp12_;
		Box _tmp13_;
		EditingToolsPhotoCanvas* _tmp14_;
		Box _tmp15_;
		EditingToolsPhotoCanvas* _tmp16_;
		_tmp10_ = self->priv->scaled_crop;
		editing_tools_crop_tool_constrain_crop (self, &_tmp10_, &_tmp11_);
		new_crop = _tmp11_;
		_tmp12_ = new_crop;
		editing_tools_crop_tool_crop_resized (self, &_tmp12_);
		_tmp13_ = new_crop;
		self->priv->scaled_crop = _tmp13_;
		_tmp14_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp15_ = new_crop;
		editing_tools_photo_canvas_invalidate_area (_tmp14_, &_tmp15_);
		_tmp16_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_repaint (_tmp16_);
		self->priv->pre_aspect_ratio = editing_tools_crop_tool_get_constraint_aspect_ratio (self);
	}
	_editing_tools_crop_tool_constraint_description_unref0 (selected_constraint);
}

static void
editing_tools_crop_tool_set_custom_constraint_mode (EditingToolsCropTool* self)
{
	gboolean _tmp0_ = FALSE;
	EditingToolsCropToolCropToolWindow* _tmp1_;
	EditingToolsCropToolCropToolWindow* _tmp8_;
	GtkBox* _tmp9_;
	EditingToolsCropToolCropToolWindow* _tmp10_;
	GtkComboBox* _tmp11_;
	EditingToolsCropToolCropToolWindow* _tmp12_;
	GtkBox* _tmp13_;
	EditingToolsCropToolCropToolWindow* _tmp14_;
	GtkButton* _tmp15_;
	EditingToolsCropToolCropToolWindow* _tmp16_;
	GtkBox* _tmp17_;
	EditingToolsCropToolCropToolWindow* _tmp18_;
	GtkBox* _tmp19_;
	EditingToolsCropToolCropToolWindow* _tmp20_;
	GtkBox* _tmp21_;
	EditingToolsCropToolCropToolWindow* _tmp22_;
	GtkComboBox* _tmp23_;
	EditingToolsCropToolCropToolWindow* _tmp24_;
	GtkBox* _tmp25_;
	EditingToolsCropToolCropToolWindow* _tmp26_;
	GtkEntry* _tmp27_;
	EditingToolsCropToolCropToolWindow* _tmp28_;
	GtkBox* _tmp29_;
	EditingToolsCropToolCropToolWindow* _tmp30_;
	GtkLabel* _tmp31_;
	EditingToolsCropToolCropToolWindow* _tmp32_;
	GtkBox* _tmp33_;
	EditingToolsCropToolCropToolWindow* _tmp34_;
	GtkEntry* _tmp35_;
	EditingToolsCropToolCropToolWindow* _tmp36_;
	GtkBox* _tmp37_;
	EditingToolsCropToolCropToolWindow* _tmp38_;
	GtkButton* _tmp39_;
	EditingToolsCropToolCropToolWindow* _tmp40_;
	GtkBox* _tmp41_;
	EditingToolsCropToolCropToolWindow* _tmp42_;
	GtkBox* _tmp43_;
	EditingToolsCropToolCropToolWindow* _tmp60_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	if (self->priv->constraint_mode == EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_CUSTOM) {
		return;
	}
	_tmp1_ = self->priv->crop_tool_window;
	if (_tmp1_->normal_width == -1) {
		_tmp0_ = TRUE;
	} else {
		EditingToolsCropToolCropToolWindow* _tmp2_;
		_tmp2_ = self->priv->crop_tool_window;
		_tmp0_ = _tmp2_->normal_height == -1;
	}
	if (_tmp0_) {
		EditingToolsCropToolCropToolWindow* _tmp3_;
		EditingToolsCropToolCropToolWindow* _tmp4_;
		EditingToolsCropToolCropToolWindow* _tmp5_;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		_tmp3_ = self->priv->crop_tool_window;
		_tmp4_ = self->priv->crop_tool_window;
		_tmp5_ = self->priv->crop_tool_window;
		gtk_window_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_window_get_type (), GtkWindow), &_tmp6_, &_tmp7_);
		_tmp4_->normal_width = _tmp6_;
		_tmp5_->normal_height = _tmp7_;
	}
	_tmp8_ = self->priv->crop_tool_window;
	_tmp9_ = _tmp8_->layout;
	_tmp10_ = self->priv->crop_tool_window;
	_tmp11_ = _tmp10_->constraint_combo;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_widget_get_type (), GtkWidget));
	_tmp12_ = self->priv->crop_tool_window;
	_tmp13_ = _tmp12_->layout;
	_tmp14_ = self->priv->crop_tool_window;
	_tmp15_ = _tmp14_->pivot_reticle_button;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_widget_get_type (), GtkWidget));
	_tmp16_ = self->priv->crop_tool_window;
	_tmp17_ = _tmp16_->layout;
	_tmp18_ = self->priv->crop_tool_window;
	_tmp19_ = _tmp18_->response_layout;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_widget_get_type (), GtkWidget));
	_tmp20_ = self->priv->crop_tool_window;
	_tmp21_ = _tmp20_->layout;
	_tmp22_ = self->priv->crop_tool_window;
	_tmp23_ = _tmp22_->constraint_combo;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, gtk_widget_get_type (), GtkWidget));
	_tmp24_ = self->priv->crop_tool_window;
	_tmp25_ = _tmp24_->layout;
	_tmp26_ = self->priv->crop_tool_window;
	_tmp27_ = _tmp26_->custom_width_entry;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, gtk_widget_get_type (), GtkWidget));
	_tmp28_ = self->priv->crop_tool_window;
	_tmp29_ = _tmp28_->layout;
	_tmp30_ = self->priv->crop_tool_window;
	_tmp31_ = _tmp30_->custom_mulsign_label;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, gtk_widget_get_type (), GtkWidget));
	_tmp32_ = self->priv->crop_tool_window;
	_tmp33_ = _tmp32_->layout;
	_tmp34_ = self->priv->crop_tool_window;
	_tmp35_ = _tmp34_->custom_height_entry;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp33_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp35_, gtk_widget_get_type (), GtkWidget));
	_tmp36_ = self->priv->crop_tool_window;
	_tmp37_ = _tmp36_->layout;
	_tmp38_ = self->priv->crop_tool_window;
	_tmp39_ = _tmp38_->pivot_reticle_button;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp37_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp39_, gtk_widget_get_type (), GtkWidget));
	_tmp40_ = self->priv->crop_tool_window;
	_tmp41_ = _tmp40_->layout;
	_tmp42_ = self->priv->crop_tool_window;
	_tmp43_ = _tmp42_->response_layout;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, gtk_widget_get_type (), GtkWidget));
	if (self->priv->reticle_orientation == EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_LANDSCAPE) {
		EditingToolsCropToolCropToolWindow* _tmp44_;
		GtkEntry* _tmp45_;
		gchar* _tmp46_;
		gchar* _tmp47_;
		EditingToolsCropToolCropToolWindow* _tmp48_;
		GtkEntry* _tmp49_;
		gchar* _tmp50_;
		gchar* _tmp51_;
		_tmp44_ = self->priv->crop_tool_window;
		_tmp45_ = _tmp44_->custom_width_entry;
		_tmp46_ = g_strdup_printf ("%d", self->priv->custom_init_width);
		_tmp47_ = _tmp46_;
		gtk_entry_set_text (_tmp45_, _tmp47_);
		_g_free0 (_tmp47_);
		_tmp48_ = self->priv->crop_tool_window;
		_tmp49_ = _tmp48_->custom_height_entry;
		_tmp50_ = g_strdup_printf ("%d", self->priv->custom_init_height);
		_tmp51_ = _tmp50_;
		gtk_entry_set_text (_tmp49_, _tmp51_);
		_g_free0 (_tmp51_);
	} else {
		EditingToolsCropToolCropToolWindow* _tmp52_;
		GtkEntry* _tmp53_;
		gchar* _tmp54_;
		gchar* _tmp55_;
		EditingToolsCropToolCropToolWindow* _tmp56_;
		GtkEntry* _tmp57_;
		gchar* _tmp58_;
		gchar* _tmp59_;
		_tmp52_ = self->priv->crop_tool_window;
		_tmp53_ = _tmp52_->custom_width_entry;
		_tmp54_ = g_strdup_printf ("%d", self->priv->custom_init_height);
		_tmp55_ = _tmp54_;
		gtk_entry_set_text (_tmp53_, _tmp55_);
		_g_free0 (_tmp55_);
		_tmp56_ = self->priv->crop_tool_window;
		_tmp57_ = _tmp56_->custom_height_entry;
		_tmp58_ = g_strdup_printf ("%d", self->priv->custom_init_width);
		_tmp59_ = _tmp58_;
		gtk_entry_set_text (_tmp57_, _tmp59_);
		_g_free0 (_tmp59_);
	}
	self->priv->custom_aspect_ratio = ((gfloat) self->priv->custom_init_width) / ((gfloat) self->priv->custom_init_height);
	_tmp60_ = self->priv->crop_tool_window;
	gtk_widget_show_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp60_, gtk_widget_get_type (), GtkWidget));
	self->priv->constraint_mode = EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_CUSTOM;
}

static void
editing_tools_crop_tool_set_normal_constraint_mode (EditingToolsCropTool* self)
{
	EditingToolsCropToolCropToolWindow* _tmp0_;
	GtkBox* _tmp1_;
	EditingToolsCropToolCropToolWindow* _tmp2_;
	GtkComboBox* _tmp3_;
	EditingToolsCropToolCropToolWindow* _tmp4_;
	GtkBox* _tmp5_;
	EditingToolsCropToolCropToolWindow* _tmp6_;
	GtkEntry* _tmp7_;
	EditingToolsCropToolCropToolWindow* _tmp8_;
	GtkBox* _tmp9_;
	EditingToolsCropToolCropToolWindow* _tmp10_;
	GtkLabel* _tmp11_;
	EditingToolsCropToolCropToolWindow* _tmp12_;
	GtkBox* _tmp13_;
	EditingToolsCropToolCropToolWindow* _tmp14_;
	GtkEntry* _tmp15_;
	EditingToolsCropToolCropToolWindow* _tmp16_;
	GtkBox* _tmp17_;
	EditingToolsCropToolCropToolWindow* _tmp18_;
	GtkButton* _tmp19_;
	EditingToolsCropToolCropToolWindow* _tmp20_;
	GtkBox* _tmp21_;
	EditingToolsCropToolCropToolWindow* _tmp22_;
	GtkBox* _tmp23_;
	EditingToolsCropToolCropToolWindow* _tmp24_;
	GtkBox* _tmp25_;
	EditingToolsCropToolCropToolWindow* _tmp26_;
	GtkComboBox* _tmp27_;
	EditingToolsCropToolCropToolWindow* _tmp28_;
	GtkBox* _tmp29_;
	EditingToolsCropToolCropToolWindow* _tmp30_;
	GtkButton* _tmp31_;
	EditingToolsCropToolCropToolWindow* _tmp32_;
	GtkBox* _tmp33_;
	EditingToolsCropToolCropToolWindow* _tmp34_;
	GtkBox* _tmp35_;
	EditingToolsCropToolCropToolWindow* _tmp36_;
	EditingToolsCropToolCropToolWindow* _tmp37_;
	EditingToolsCropToolCropToolWindow* _tmp38_;
	EditingToolsCropToolCropToolWindow* _tmp39_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	if (self->priv->constraint_mode == EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_NORMAL) {
		return;
	}
	_tmp0_ = self->priv->crop_tool_window;
	_tmp1_ = _tmp0_->layout;
	_tmp2_ = self->priv->crop_tool_window;
	_tmp3_ = _tmp2_->constraint_combo;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget));
	_tmp4_ = self->priv->crop_tool_window;
	_tmp5_ = _tmp4_->layout;
	_tmp6_ = self->priv->crop_tool_window;
	_tmp7_ = _tmp6_->custom_width_entry;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget));
	_tmp8_ = self->priv->crop_tool_window;
	_tmp9_ = _tmp8_->layout;
	_tmp10_ = self->priv->crop_tool_window;
	_tmp11_ = _tmp10_->custom_mulsign_label;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_widget_get_type (), GtkWidget));
	_tmp12_ = self->priv->crop_tool_window;
	_tmp13_ = _tmp12_->layout;
	_tmp14_ = self->priv->crop_tool_window;
	_tmp15_ = _tmp14_->custom_height_entry;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_widget_get_type (), GtkWidget));
	_tmp16_ = self->priv->crop_tool_window;
	_tmp17_ = _tmp16_->layout;
	_tmp18_ = self->priv->crop_tool_window;
	_tmp19_ = _tmp18_->pivot_reticle_button;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_widget_get_type (), GtkWidget));
	_tmp20_ = self->priv->crop_tool_window;
	_tmp21_ = _tmp20_->layout;
	_tmp22_ = self->priv->crop_tool_window;
	_tmp23_ = _tmp22_->response_layout;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, gtk_widget_get_type (), GtkWidget));
	_tmp24_ = self->priv->crop_tool_window;
	_tmp25_ = _tmp24_->layout;
	_tmp26_ = self->priv->crop_tool_window;
	_tmp27_ = _tmp26_->constraint_combo;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, gtk_widget_get_type (), GtkWidget));
	_tmp28_ = self->priv->crop_tool_window;
	_tmp29_ = _tmp28_->layout;
	_tmp30_ = self->priv->crop_tool_window;
	_tmp31_ = _tmp30_->pivot_reticle_button;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, gtk_widget_get_type (), GtkWidget));
	_tmp32_ = self->priv->crop_tool_window;
	_tmp33_ = _tmp32_->layout;
	_tmp34_ = self->priv->crop_tool_window;
	_tmp35_ = _tmp34_->response_layout;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp33_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp35_, gtk_widget_get_type (), GtkWidget));
	_tmp36_ = self->priv->crop_tool_window;
	_tmp37_ = self->priv->crop_tool_window;
	_tmp38_ = self->priv->crop_tool_window;
	gtk_window_resize (G_TYPE_CHECK_INSTANCE_CAST (_tmp36_, gtk_window_get_type (), GtkWindow), _tmp37_->normal_width, _tmp38_->normal_height);
	_tmp39_ = self->priv->crop_tool_window;
	gtk_widget_show_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp39_, gtk_widget_get_type (), GtkWidget));
	self->priv->constraint_mode = EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_NORMAL;
}

static void
editing_tools_crop_tool_constrain_crop (EditingToolsCropTool* self,
                                        Box* crop,
                                        Box* result)
{
	gfloat user_aspect_ratio = 0.0F;
	gfloat old_area = 0.0F;
	Dimensions image_size = {0};
	Dimensions _tmp1_ = {0};
	gdouble angle = 0.0;
	EditingToolsPhotoCanvas* _tmp2_;
	Photo* _tmp3_;
	Photo* _tmp4_;
	gdouble _tmp5_ = 0.0;
	Box _tmp6_;
	Dimensions _tmp7_;
	Dimensions _tmp8_;
	Box _tmp9_ = {0};
	Box _tmp10_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (crop != NULL);
	user_aspect_ratio = editing_tools_crop_tool_get_constraint_aspect_ratio (self);
	if (user_aspect_ratio == EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
		Box _tmp0_;
		_tmp0_ = *crop;
		*result = _tmp0_;
		return;
	}
	old_area = (gfloat) (box_get_width (crop) * box_get_height (crop));
	box_adjust_height (crop, (gint) sqrt ((gdouble) (old_area / user_aspect_ratio)));
	box_adjust_width (crop, (gint) sqrt ((gdouble) (old_area * user_aspect_ratio)));
	editing_tools_crop_tool_get_photo_dimensions (self, &_tmp1_);
	image_size = _tmp1_;
	_tmp2_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp3_ = editing_tools_photo_canvas_get_photo (_tmp2_);
	_tmp4_ = _tmp3_;
	photo_get_straighten (_tmp4_, &_tmp5_);
	angle = _tmp5_;
	_g_object_unref0 (_tmp4_);
	_tmp6_ = *crop;
	_tmp7_ = image_size;
	_tmp8_ = image_size;
	clamp_inside_rotated_image (&_tmp6_, _tmp7_.width, _tmp8_.height, angle, FALSE, &_tmp9_);
	*crop = _tmp9_;
	if (((gfloat) box_get_width (crop)) >= (box_get_height (crop) * user_aspect_ratio)) {
		box_adjust_width (crop, (gint) (box_get_height (crop) * user_aspect_ratio));
	} else {
		box_adjust_height (crop, (gint) (box_get_width (crop) / user_aspect_ratio));
	}
	_tmp10_ = *crop;
	*result = _tmp10_;
	return;
}

static EditingToolsCropToolConstraintDescription*
editing_tools_crop_tool_get_last_constraint (EditingToolsCropTool* self,
                                             gint* index)
{
	gint _vala_index = 0;
	ConfigFacade* _tmp0_;
	ConfigFacade* _tmp1_;
	EditingToolsCropToolConstraintDescription* _tmp2_ = NULL;
	EditingToolsCropToolConstraintDescription** _tmp3_;
	gint _tmp3__length1;
	EditingToolsCropToolConstraintDescription* _tmp6_;
	EditingToolsCropToolConstraintDescription* result;
	g_return_val_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self), NULL);
	_tmp0_ = config_facade_get_instance ();
	_tmp1_ = _tmp0_;
	_vala_index = configuration_facade_get_last_crop_menu_choice (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
	_g_object_unref0 (_tmp1_);
	_tmp3_ = self->priv->constraints;
	_tmp3__length1 = self->priv->constraints_length1;
	if (_vala_index < _tmp3__length1) {
		EditingToolsCropToolConstraintDescription** _tmp4_;
		gint _tmp4__length1;
		EditingToolsCropToolConstraintDescription* _tmp5_;
		_tmp4_ = self->priv->constraints;
		_tmp4__length1 = self->priv->constraints_length1;
		_tmp5_ = _tmp4_[_vala_index];
		_tmp2_ = _tmp5_;
	} else {
		_tmp2_ = NULL;
	}
	_tmp6_ = _editing_tools_crop_tool_constraint_description_ref0 (_tmp2_);
	result = _tmp6_;
	if (index) {
		*index = _vala_index;
	}
	return result;
}

static void
editing_tools_crop_tool_real_activate (EditingToolsEditingTool* base,
                                       EditingToolsPhotoCanvas* canvas)
{
	EditingToolsCropTool * self;
	cairo_t* _tmp0_;
	cairo_t* _tmp1_;
	Dimensions _tmp2_ = {0};
	cairo_surface_t* _tmp3_;
	GdkRectangle _tmp4_ = {0};
	GdkRectangle _tmp5_ = {0};
	cairo_surface_t* _tmp6_;
	cairo_t* ctx = NULL;
	cairo_surface_t* _tmp7_;
	cairo_t* _tmp8_;
	cairo_t* _tmp9_;
	cairo_t* _tmp10_;
	GtkWindow* _tmp11_;
	GtkWindow* _tmp12_;
	EditingToolsCropToolCropToolWindow* _tmp13_;
	EditingToolsCropToolCropToolWindow* _tmp14_;
	GtkComboBox* _tmp15_;
	GtkListStore* _tmp16_;
	Photo* _tmp17_;
	Photo* _tmp18_;
	gboolean _tmp19_;
	Dimensions uncropped_dim = {0};
	Photo* _tmp40_;
	Photo* _tmp41_;
	Dimensions _tmp42_ = {0};
	Dimensions _tmp43_;
	Box crop = {0};
	Photo* _tmp44_;
	Photo* _tmp45_;
	Box _tmp46_ = {0};
	gboolean _tmp47_;
	gboolean _tmp48_;
	Dimensions _tmp53_;
	GdkRectangle _tmp54_ = {0};
	Dimensions _tmp55_ = {0};
	Box _tmp56_ = {0};
	ConfigFacade* _tmp57_;
	ConfigFacade* _tmp58_;
	ConfigFacade* _tmp59_;
	ConfigFacade* _tmp60_;
	EditingToolsCropToolCropToolWindow* _tmp61_;
	Photo* _tmp62_;
	Photo* _tmp63_;
	gboolean _tmp64_;
	Box new_crop = {0};
	Box _tmp71_;
	Box _tmp72_ = {0};
	Box _tmp73_;
	Box _tmp74_;
	Box _tmp75_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	editing_tools_crop_tool_bind_canvas_handlers (self, canvas);
	_tmp0_ = editing_tools_photo_canvas_get_default_ctx (canvas);
	_tmp1_ = _tmp0_;
	editing_tools_photo_canvas_get_surface_dim (canvas, &_tmp2_);
	editing_tools_crop_tool_prepare_ctx (self, _tmp1_, &_tmp2_);
	_cairo_destroy0 (_tmp1_);
	_tmp3_ = self->priv->crop_surface;
	if (_tmp3_ != NULL) {
		_cairo_surface_destroy0 (self->priv->crop_surface);
		self->priv->crop_surface = NULL;
	}
	editing_tools_photo_canvas_get_scaled_pixbuf_position (canvas, &_tmp4_);
	editing_tools_photo_canvas_get_scaled_pixbuf_position (canvas, &_tmp5_);
	_tmp6_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, _tmp4_.width, _tmp5_.height);
	_cairo_surface_destroy0 (self->priv->crop_surface);
	self->priv->crop_surface = _tmp6_;
	_tmp7_ = self->priv->crop_surface;
	_tmp8_ = cairo_create (_tmp7_);
	ctx = _tmp8_;
	_tmp9_ = ctx;
	cairo_set_source_rgba (_tmp9_, 0.0, 0.0, 0.0, 1.0);
	_tmp10_ = ctx;
	cairo_paint (_tmp10_);
	_tmp11_ = editing_tools_photo_canvas_get_container (canvas);
	_tmp12_ = _tmp11_;
	_tmp13_ = editing_tools_crop_tool_crop_tool_window_new (_tmp12_);
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->crop_tool_window);
	self->priv->crop_tool_window = _tmp13_;
	_g_object_unref0 (_tmp12_);
	_tmp14_ = self->priv->crop_tool_window;
	_tmp15_ = _tmp14_->constraint_combo;
	_tmp16_ = self->priv->constraint_list;
	gtk_combo_box_set_model (_tmp15_, G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_tree_model_get_type (), GtkTreeModel));
	_tmp17_ = editing_tools_photo_canvas_get_photo (canvas);
	_tmp18_ = _tmp17_;
	_tmp19_ = !photo_has_crop (_tmp18_);
	_g_object_unref0 (_tmp18_);
	if (_tmp19_) {
		gint index = 0;
		EditingToolsCropToolConstraintDescription* desc = NULL;
		gint _tmp20_ = 0;
		EditingToolsCropToolConstraintDescription* _tmp21_;
		gboolean _tmp22_ = FALSE;
		EditingToolsCropToolConstraintDescription* _tmp23_;
		_tmp21_ = editing_tools_crop_tool_get_last_constraint (self, &_tmp20_);
		index = _tmp20_;
		desc = _tmp21_;
		_tmp23_ = desc;
		if (_tmp23_ != NULL) {
			EditingToolsCropToolConstraintDescription* _tmp24_;
			_tmp24_ = desc;
			_tmp22_ = !editing_tools_crop_tool_constraint_description_is_separator (_tmp24_);
		} else {
			_tmp22_ = FALSE;
		}
		if (_tmp22_) {
			EditingToolsCropToolCropToolWindow* _tmp25_;
			GtkComboBox* _tmp26_;
			_tmp25_ = self->priv->crop_tool_window;
			_tmp26_ = _tmp25_->constraint_combo;
			gtk_combo_box_set_active (_tmp26_, index);
		}
		_editing_tools_crop_tool_constraint_description_unref0 (desc);
	} else {
		Photo* photo = NULL;
		Photo* _tmp27_;
		Dimensions cropped_dim = {0};
		Photo* _tmp28_;
		Dimensions _tmp29_ = {0};
		gfloat ratio = 0.0F;
		Dimensions _tmp30_;
		Dimensions _tmp31_;
		_tmp27_ = editing_tools_photo_canvas_get_photo (canvas);
		photo = _tmp27_;
		_tmp28_ = photo;
		media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_NONE, &_tmp29_);
		cropped_dim = _tmp29_;
		_tmp30_ = cropped_dim;
		_tmp31_ = cropped_dim;
		ratio = ((gfloat) _tmp30_.width) / ((gfloat) _tmp31_.height);
		{
			gint index = 0;
			index = 1;
			{
				gboolean _tmp32_ = FALSE;
				_tmp32_ = TRUE;
				while (TRUE) {
					EditingToolsCropToolConstraintDescription** _tmp34_;
					gint _tmp34__length1;
					EditingToolsCropToolConstraintDescription** _tmp35_;
					gint _tmp35__length1;
					EditingToolsCropToolConstraintDescription* _tmp36_;
					Photo* _tmp37_;
					if (!_tmp32_) {
						gint _tmp33_;
						_tmp33_ = index;
						index = _tmp33_ + 1;
					}
					_tmp32_ = FALSE;
					_tmp34_ = self->priv->constraints;
					_tmp34__length1 = self->priv->constraints_length1;
					if (!(index < _tmp34__length1)) {
						break;
					}
					_tmp35_ = self->priv->constraints;
					_tmp35__length1 = self->priv->constraints_length1;
					_tmp36_ = _tmp35_[index];
					_tmp37_ = photo;
					if (fabs ((gdouble) (ratio - editing_tools_crop_tool_get_constraint_aspect_ratio_for_constraint (self, _tmp36_, _tmp37_))) < 0.005) {
						EditingToolsCropToolCropToolWindow* _tmp38_;
						GtkComboBox* _tmp39_;
						_tmp38_ = self->priv->crop_tool_window;
						_tmp39_ = _tmp38_->constraint_combo;
						gtk_combo_box_set_active (_tmp39_, index);
					}
				}
			}
		}
		_g_object_unref0 (photo);
	}
	editing_tools_crop_tool_update_pivot_button_state (self);
	self->priv->reticle_orientation = EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_LANDSCAPE;
	editing_tools_crop_tool_bind_window_handlers (self);
	_tmp40_ = editing_tools_photo_canvas_get_photo (canvas);
	_tmp41_ = _tmp40_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_CROP, &_tmp42_);
	_tmp43_ = _tmp42_;
	_g_object_unref0 (_tmp41_);
	uncropped_dim = _tmp43_;
	_tmp44_ = editing_tools_photo_canvas_get_photo (canvas);
	_tmp45_ = _tmp44_;
	_tmp47_ = photo_get_crop (_tmp45_, &_tmp46_, PHOTO_EXCEPTION_NONE);
	crop = _tmp46_;
	_tmp48_ = !_tmp47_;
	_g_object_unref0 (_tmp45_);
	if (_tmp48_) {
		gint xofs = 0;
		Dimensions _tmp49_;
		gint yofs = 0;
		Dimensions _tmp50_;
		Dimensions _tmp51_;
		Dimensions _tmp52_;
		_tmp49_ = uncropped_dim;
		xofs = (gint) (_tmp49_.width * EDITING_TOOLS_CROP_TOOL_CROP_INIT_X_PCT);
		_tmp50_ = uncropped_dim;
		yofs = (gint) (_tmp50_.height * EDITING_TOOLS_CROP_TOOL_CROP_INIT_Y_PCT);
		_tmp51_ = uncropped_dim;
		_tmp52_ = uncropped_dim;
		box_init (&crop, xofs, yofs, _tmp51_.width - xofs, _tmp52_.height - yofs);
	}
	_tmp53_ = uncropped_dim;
	editing_tools_photo_canvas_get_scaled_pixbuf_position (canvas, &_tmp54_);
	dimensions_for_rectangle (&_tmp54_, &_tmp55_);
	box_get_scaled_similar (&crop, &_tmp53_, &_tmp55_, &_tmp56_);
	self->priv->scaled_crop = _tmp56_;
	_tmp57_ = config_facade_get_instance ();
	_tmp58_ = _tmp57_;
	self->priv->custom_width = configuration_facade_get_last_crop_width (G_TYPE_CHECK_INSTANCE_CAST (_tmp58_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
	_g_object_unref0 (_tmp58_);
	_tmp59_ = config_facade_get_instance ();
	_tmp60_ = _tmp59_;
	self->priv->custom_height = configuration_facade_get_last_crop_height (G_TYPE_CHECK_INSTANCE_CAST (_tmp60_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
	_g_object_unref0 (_tmp60_);
	self->priv->custom_init_width = self->priv->custom_width;
	self->priv->custom_init_height = self->priv->custom_height;
	self->priv->pre_aspect_ratio = ((gfloat) self->priv->custom_init_width) / ((gfloat) self->priv->custom_init_height);
	self->priv->constraint_mode = EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_NORMAL;
	EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_crop_tool_parent_class)->activate (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), canvas);
	_tmp61_ = self->priv->crop_tool_window;
	gtk_widget_show_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp61_, gtk_widget_get_type (), GtkWidget));
	_tmp62_ = editing_tools_photo_canvas_get_photo (canvas);
	_tmp63_ = _tmp62_;
	_tmp64_ = !photo_has_crop (_tmp63_);
	_g_object_unref0 (_tmp63_);
	if (_tmp64_) {
		EditingToolsCropToolConstraintDescription* desc = NULL;
		EditingToolsCropToolConstraintDescription* _tmp65_;
		gboolean _tmp66_ = FALSE;
		gboolean _tmp67_ = FALSE;
		EditingToolsCropToolConstraintDescription* _tmp68_;
		_tmp65_ = editing_tools_crop_tool_get_last_constraint (self, NULL);
		desc = _tmp65_;
		_tmp68_ = desc;
		if (_tmp68_ != NULL) {
			EditingToolsCropToolConstraintDescription* _tmp69_;
			_tmp69_ = desc;
			_tmp67_ = !editing_tools_crop_tool_constraint_description_is_separator (_tmp69_);
		} else {
			_tmp67_ = FALSE;
		}
		if (_tmp67_) {
			EditingToolsCropToolConstraintDescription* _tmp70_;
			_tmp70_ = desc;
			_tmp66_ = _tmp70_->aspect_ratio == EDITING_TOOLS_CROP_TOOL_CUSTOM_ASPECT_RATIO;
		} else {
			_tmp66_ = FALSE;
		}
		if (_tmp66_) {
			editing_tools_crop_tool_set_custom_constraint_mode (self);
		}
		_editing_tools_crop_tool_constraint_description_unref0 (desc);
	}
	_tmp71_ = self->priv->scaled_crop;
	editing_tools_crop_tool_constrain_crop (self, &_tmp71_, &_tmp72_);
	new_crop = _tmp72_;
	_tmp73_ = new_crop;
	editing_tools_crop_tool_crop_resized (self, &_tmp73_);
	_tmp74_ = new_crop;
	self->priv->scaled_crop = _tmp74_;
	_tmp75_ = new_crop;
	editing_tools_photo_canvas_invalidate_area (canvas, &_tmp75_);
	editing_tools_photo_canvas_repaint (canvas);
	self->priv->pre_aspect_ratio = editing_tools_crop_tool_get_constraint_aspect_ratio (self);
	_cairo_destroy0 (ctx);
}

static void
_editing_tools_crop_tool_prepare_ctx_editing_tools_photo_canvas_new_surface (EditingToolsPhotoCanvas* _sender,
                                                                             cairo_t* ctx,
                                                                             Dimensions* dim,
                                                                             gpointer self)
{
	editing_tools_crop_tool_prepare_ctx ((EditingToolsCropTool*) self, ctx, dim);
}

static void
_editing_tools_crop_tool_on_resized_pixbuf_editing_tools_photo_canvas_resized_scaled_pixbuf (EditingToolsPhotoCanvas* _sender,
                                                                                             Dimensions* old_dim,
                                                                                             GdkPixbuf* scaled,
                                                                                             GdkRectangle* scaled_position,
                                                                                             gpointer self)
{
	editing_tools_crop_tool_on_resized_pixbuf ((EditingToolsCropTool*) self, old_dim, scaled, scaled_position);
}

static void
editing_tools_crop_tool_bind_canvas_handlers (EditingToolsCropTool* self,
                                              EditingToolsPhotoCanvas* canvas)
{
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	g_signal_connect (canvas, "new-surface", (GCallback) _editing_tools_crop_tool_prepare_ctx_editing_tools_photo_canvas_new_surface, self);
	g_signal_connect (canvas, "resized-scaled-pixbuf", (GCallback) _editing_tools_crop_tool_on_resized_pixbuf_editing_tools_photo_canvas_resized_scaled_pixbuf, self);
}

static void
editing_tools_crop_tool_unbind_canvas_handlers (EditingToolsCropTool* self,
                                                EditingToolsPhotoCanvas* canvas)
{
	guint _tmp0_;
	guint _tmp1_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	g_signal_parse_name ("new-surface", EDITING_TOOLS_TYPE_PHOTO_CANVAS, &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (canvas, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _editing_tools_crop_tool_prepare_ctx_editing_tools_photo_canvas_new_surface, self);
	g_signal_parse_name ("resized-scaled-pixbuf", EDITING_TOOLS_TYPE_PHOTO_CANVAS, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (canvas, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _editing_tools_crop_tool_on_resized_pixbuf_editing_tools_photo_canvas_resized_scaled_pixbuf, self);
}

static void
_editing_tools_crop_tool_on_crop_ok_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self)
{
	editing_tools_crop_tool_on_crop_ok ((EditingToolsCropTool*) self);
}

static void
_editing_tools_editing_tool_notify_cancel_gtk_button_clicked (GtkButton* _sender,
                                                              gpointer self)
{
	editing_tools_editing_tool_notify_cancel ((EditingToolsEditingTool*) self);
}

static void
_editing_tools_crop_tool_constraint_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                   gpointer self)
{
	editing_tools_crop_tool_constraint_changed ((EditingToolsCropTool*) self);
}

static void
_editing_tools_crop_tool_on_pivot_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                     gpointer self)
{
	editing_tools_crop_tool_on_pivot_button_clicked ((EditingToolsCropTool*) self);
}

static gboolean
_editing_tools_crop_tool_on_width_entry_focus_out_gtk_widget_focus_out_event (GtkWidget* _sender,
                                                                              GdkEventFocus* event,
                                                                              gpointer self)
{
	gboolean result;
	result = editing_tools_crop_tool_on_width_entry_focus_out ((EditingToolsCropTool*) self, event);
	return result;
}

static gboolean
_editing_tools_crop_tool_on_height_entry_focus_out_gtk_widget_focus_out_event (GtkWidget* _sender,
                                                                               GdkEventFocus* event,
                                                                               gpointer self)
{
	gboolean result;
	result = editing_tools_crop_tool_on_height_entry_focus_out ((EditingToolsCropTool*) self, event);
	return result;
}

static void
_editing_tools_crop_tool_on_width_insert_text_gtk_editable_insert_text (GtkEditable* _sender,
                                                                        const gchar* new_text,
                                                                        gint new_text_length,
                                                                        gint* position,
                                                                        gpointer self)
{
	editing_tools_crop_tool_on_width_insert_text ((EditingToolsCropTool*) self, new_text, new_text_length, position);
}

static void
_editing_tools_crop_tool_on_height_insert_text_gtk_editable_insert_text (GtkEditable* _sender,
                                                                         const gchar* new_text,
                                                                         gint new_text_length,
                                                                         gint* position,
                                                                         gpointer self)
{
	editing_tools_crop_tool_on_height_insert_text ((EditingToolsCropTool*) self, new_text, new_text_length, position);
}

static void
editing_tools_crop_tool_bind_window_handlers (EditingToolsCropTool* self)
{
	EditingToolsCropToolCropToolWindow* _tmp0_;
	EditingToolsCropToolCropToolWindow* _tmp1_;
	GtkButton* _tmp2_;
	EditingToolsCropToolCropToolWindow* _tmp3_;
	GtkButton* _tmp4_;
	EditingToolsCropToolCropToolWindow* _tmp5_;
	GtkComboBox* _tmp6_;
	EditingToolsCropToolCropToolWindow* _tmp7_;
	GtkButton* _tmp8_;
	EditingToolsCropToolCropToolWindow* _tmp9_;
	GtkEntry* _tmp10_;
	EditingToolsCropToolCropToolWindow* _tmp11_;
	GtkEntry* _tmp12_;
	EditingToolsCropToolCropToolWindow* _tmp13_;
	GtkEntry* _tmp14_;
	EditingToolsCropToolCropToolWindow* _tmp15_;
	GtkEntry* _tmp16_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	_tmp0_ = self->priv->crop_tool_window;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_widget_get_type (), GtkWidget), "key-press-event", (GCallback) _editing_tools_editing_tool_on_keypress_gtk_widget_key_press_event, G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
	_tmp1_ = self->priv->crop_tool_window;
	_tmp2_ = _tmp1_->ok_button;
	g_signal_connect (_tmp2_, "clicked", (GCallback) _editing_tools_crop_tool_on_crop_ok_gtk_button_clicked, self);
	_tmp3_ = self->priv->crop_tool_window;
	_tmp4_ = _tmp3_->cancel_button;
	g_signal_connect (_tmp4_, "clicked", (GCallback) _editing_tools_editing_tool_notify_cancel_gtk_button_clicked, G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
	_tmp5_ = self->priv->crop_tool_window;
	_tmp6_ = _tmp5_->constraint_combo;
	g_signal_connect (_tmp6_, "changed", (GCallback) _editing_tools_crop_tool_constraint_changed_gtk_combo_box_changed, self);
	_tmp7_ = self->priv->crop_tool_window;
	_tmp8_ = _tmp7_->pivot_reticle_button;
	g_signal_connect (_tmp8_, "clicked", (GCallback) _editing_tools_crop_tool_on_pivot_button_clicked_gtk_button_clicked, self);
	_tmp9_ = self->priv->crop_tool_window;
	_tmp10_ = _tmp9_->custom_width_entry;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_widget_get_type (), GtkWidget), "focus-out-event", (GCallback) _editing_tools_crop_tool_on_width_entry_focus_out_gtk_widget_focus_out_event, self);
	_tmp11_ = self->priv->crop_tool_window;
	_tmp12_ = _tmp11_->custom_height_entry;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget), "focus-out-event", (GCallback) _editing_tools_crop_tool_on_height_entry_focus_out_gtk_widget_focus_out_event, self);
	_tmp13_ = self->priv->crop_tool_window;
	_tmp14_ = _tmp13_->custom_width_entry;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_editable_get_type (), GtkEditable), "insert-text", (GCallback) _editing_tools_crop_tool_on_width_insert_text_gtk_editable_insert_text, self);
	_tmp15_ = self->priv->crop_tool_window;
	_tmp16_ = _tmp15_->custom_height_entry;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_editable_get_type (), GtkEditable), "insert-text", (GCallback) _editing_tools_crop_tool_on_height_insert_text_gtk_editable_insert_text, self);
}

static void
editing_tools_crop_tool_unbind_window_handlers (EditingToolsCropTool* self)
{
	EditingToolsCropToolCropToolWindow* _tmp0_;
	guint _tmp1_;
	EditingToolsCropToolCropToolWindow* _tmp2_;
	GtkButton* _tmp3_;
	guint _tmp4_;
	EditingToolsCropToolCropToolWindow* _tmp5_;
	GtkButton* _tmp6_;
	guint _tmp7_;
	EditingToolsCropToolCropToolWindow* _tmp8_;
	GtkComboBox* _tmp9_;
	guint _tmp10_;
	EditingToolsCropToolCropToolWindow* _tmp11_;
	GtkButton* _tmp12_;
	guint _tmp13_;
	EditingToolsCropToolCropToolWindow* _tmp14_;
	GtkEntry* _tmp15_;
	guint _tmp16_;
	EditingToolsCropToolCropToolWindow* _tmp17_;
	GtkEntry* _tmp18_;
	guint _tmp19_;
	EditingToolsCropToolCropToolWindow* _tmp20_;
	GtkEntry* _tmp21_;
	guint _tmp22_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	_tmp0_ = self->priv->crop_tool_window;
	g_signal_parse_name ("key-press-event", gtk_widget_get_type (), &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _editing_tools_editing_tool_on_keypress_gtk_widget_key_press_event, G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
	_tmp2_ = self->priv->crop_tool_window;
	_tmp3_ = _tmp2_->ok_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp4_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp3_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _editing_tools_crop_tool_on_crop_ok_gtk_button_clicked, self);
	_tmp5_ = self->priv->crop_tool_window;
	_tmp6_ = _tmp5_->cancel_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp7_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _editing_tools_editing_tool_notify_cancel_gtk_button_clicked, G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
	_tmp8_ = self->priv->crop_tool_window;
	_tmp9_ = _tmp8_->constraint_combo;
	g_signal_parse_name ("changed", gtk_combo_box_get_type (), &_tmp10_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp9_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp10_, 0, NULL, (GCallback) _editing_tools_crop_tool_constraint_changed_gtk_combo_box_changed, self);
	_tmp11_ = self->priv->crop_tool_window;
	_tmp12_ = _tmp11_->pivot_reticle_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp13_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp12_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp13_, 0, NULL, (GCallback) _editing_tools_crop_tool_on_pivot_button_clicked_gtk_button_clicked, self);
	_tmp14_ = self->priv->crop_tool_window;
	_tmp15_ = _tmp14_->custom_width_entry;
	g_signal_parse_name ("focus-out-event", gtk_widget_get_type (), &_tmp16_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp16_, 0, NULL, (GCallback) _editing_tools_crop_tool_on_width_entry_focus_out_gtk_widget_focus_out_event, self);
	_tmp17_ = self->priv->crop_tool_window;
	_tmp18_ = _tmp17_->custom_height_entry;
	g_signal_parse_name ("focus-out-event", gtk_widget_get_type (), &_tmp19_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp19_, 0, NULL, (GCallback) _editing_tools_crop_tool_on_height_entry_focus_out_gtk_widget_focus_out_event, self);
	_tmp20_ = self->priv->crop_tool_window;
	_tmp21_ = _tmp20_->custom_width_entry;
	g_signal_parse_name ("insert-text", gtk_editable_get_type (), &_tmp22_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, gtk_editable_get_type (), GtkEditable), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp22_, 0, NULL, (GCallback) _editing_tools_crop_tool_on_width_insert_text_gtk_editable_insert_text, self);
}

static gboolean
editing_tools_crop_tool_real_on_keypress (EditingToolsEditingTool* base,
                                          GdkEventKey* event)
{
	EditingToolsCropTool * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp2_ = gdk_keyval_name (event->keyval);
	if (g_strcmp0 (_tmp2_, "KP_Enter") == 0) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp3_;
		_tmp3_ = gdk_keyval_name (event->keyval);
		_tmp1_ = g_strcmp0 (_tmp3_, "Enter") == 0;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp4_;
		_tmp4_ = gdk_keyval_name (event->keyval);
		_tmp0_ = g_strcmp0 (_tmp4_, "Return") == 0;
	}
	if (_tmp0_) {
		editing_tools_crop_tool_on_crop_ok (self);
		result = TRUE;
		return result;
	}
	result = EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_crop_tool_parent_class)->on_keypress (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), event);
	return result;
}

static void
editing_tools_crop_tool_on_pivot_button_clicked (EditingToolsCropTool* self)
{
	EditingToolsCropToolConstraintDescription* _tmp0_;
	EditingToolsCropToolConstraintDescription* _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	_tmp0_ = editing_tools_crop_tool_get_selected_constraint (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_->aspect_ratio == EDITING_TOOLS_CROP_TOOL_CUSTOM_ASPECT_RATIO;
	_editing_tools_crop_tool_constraint_description_unref0 (_tmp1_);
	if (_tmp2_) {
		gchar* width_text = NULL;
		EditingToolsCropToolCropToolWindow* _tmp3_;
		GtkEntry* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* height_text = NULL;
		EditingToolsCropToolCropToolWindow* _tmp7_;
		GtkEntry* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		EditingToolsCropToolCropToolWindow* _tmp11_;
		GtkEntry* _tmp12_;
		const gchar* _tmp13_;
		EditingToolsCropToolCropToolWindow* _tmp14_;
		GtkEntry* _tmp15_;
		const gchar* _tmp16_;
		gint temp = 0;
		_tmp3_ = self->priv->crop_tool_window;
		_tmp4_ = _tmp3_->custom_width_entry;
		_tmp5_ = gtk_entry_get_text (_tmp4_);
		_tmp6_ = g_strdup (_tmp5_);
		width_text = _tmp6_;
		_tmp7_ = self->priv->crop_tool_window;
		_tmp8_ = _tmp7_->custom_height_entry;
		_tmp9_ = gtk_entry_get_text (_tmp8_);
		_tmp10_ = g_strdup (_tmp9_);
		height_text = _tmp10_;
		_tmp11_ = self->priv->crop_tool_window;
		_tmp12_ = _tmp11_->custom_width_entry;
		_tmp13_ = height_text;
		gtk_entry_set_text (_tmp12_, _tmp13_);
		_tmp14_ = self->priv->crop_tool_window;
		_tmp15_ = _tmp14_->custom_height_entry;
		_tmp16_ = width_text;
		gtk_entry_set_text (_tmp15_, _tmp16_);
		temp = self->priv->custom_width;
		self->priv->custom_width = self->priv->custom_height;
		self->priv->custom_height = temp;
		_g_free0 (height_text);
		_g_free0 (width_text);
	}
	self->priv->reticle_orientation = editing_tools_crop_tool_reticle_orientation_toggle (self->priv->reticle_orientation);
	editing_tools_crop_tool_constraint_changed (self);
}

static void
editing_tools_crop_tool_real_deactivate (EditingToolsEditingTool* base)
{
	EditingToolsCropTool * self;
	EditingToolsPhotoCanvas* _tmp0_;
	EditingToolsCropToolCropToolWindow* _tmp2_;
	EditingToolsPhotoCanvas* _tmp5_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	if (_tmp0_ != NULL) {
		EditingToolsPhotoCanvas* _tmp1_;
		_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_crop_tool_unbind_canvas_handlers (self, _tmp1_);
	}
	_tmp2_ = self->priv->crop_tool_window;
	if (_tmp2_ != NULL) {
		EditingToolsCropToolCropToolWindow* _tmp3_;
		EditingToolsCropToolCropToolWindow* _tmp4_;
		editing_tools_crop_tool_unbind_window_handlers (self);
		_tmp3_ = self->priv->crop_tool_window;
		gtk_widget_hide (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget));
		_tmp4_ = self->priv->crop_tool_window;
		gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_widget_get_type (), GtkWidget));
		_g_object_unref0 (self->priv->crop_tool_window);
		self->priv->crop_tool_window = NULL;
	}
	_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	if (_tmp5_ != NULL) {
		EditingToolsPhotoCanvas* _tmp6_;
		_tmp6_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_set_cursor (_tmp6_, GDK_LEFT_PTR);
	}
	_cairo_surface_destroy0 (self->priv->crop_surface);
	self->priv->crop_surface = NULL;
	EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_crop_tool_parent_class)->deactivate (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
}

static EditingToolsEditingToolWindow*
editing_tools_crop_tool_real_get_tool_window (EditingToolsEditingTool* base)
{
	EditingToolsCropTool * self;
	EditingToolsCropToolCropToolWindow* _tmp0_;
	EditingToolsEditingToolWindow* _tmp1_;
	EditingToolsEditingToolWindow* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	_tmp0_ = self->priv->crop_tool_window;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow));
	result = _tmp1_;
	return result;
}

static GdkPixbuf*
editing_tools_crop_tool_real_get_display_pixbuf (EditingToolsEditingTool* base,
                                                 Scaling* scaling,
                                                 Photo* photo,
                                                 Dimensions* max_dim,
                                                 GError** error)
{
	EditingToolsCropTool * self;
	Dimensions _vala_max_dim = {0};
	Dimensions _tmp0_ = {0};
	GdkPixbuf* _tmp1_ = NULL;
	Scaling _tmp2_;
	GdkPixbuf* _tmp3_;
	GdkPixbuf* _tmp4_;
	GError* _inner_error0_ = NULL;
	GdkPixbuf* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	g_return_val_if_fail (scaling != NULL, NULL);
	g_return_val_if_fail (IS_PHOTO (photo), NULL);
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (photo, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_CROP, &_tmp0_);
	_vala_max_dim = _tmp0_;
	_tmp2_ = *scaling;
	_tmp3_ = photo_get_pixbuf_with_options (photo, &_tmp2_, PHOTO_EXCEPTION_CROP, BACKING_FETCH_MODE_BASELINE, &_inner_error0_);
	_tmp1_ = _tmp3_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp4_ = _tmp1_;
	_tmp1_ = NULL;
	result = _tmp4_;
	_g_object_unref0 (_tmp1_);
	if (max_dim) {
		*max_dim = _vala_max_dim;
	}
	return result;
}

static void
editing_tools_crop_tool_prepare_ctx (EditingToolsCropTool* self,
                                     cairo_t* ctx,
                                     Dimensions* dim)
{
	gdouble scale = 0.0;
	cairo_surface_t* _tmp0_;
	cairo_t* _tmp1_;
	cairo_t* _tmp2_;
	cairo_t* _tmp3_;
	cairo_surface_t* _tmp4_;
	cairo_t* _tmp5_;
	cairo_t* _tmp6_;
	cairo_t* _tmp7_;
	cairo_surface_t* _tmp8_;
	cairo_t* _tmp9_;
	cairo_t* _tmp10_;
	cairo_t* _tmp11_;
	cairo_surface_t* _tmp12_;
	cairo_t* _tmp13_;
	cairo_t* _tmp14_;
	cairo_t* _tmp15_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (dim != NULL);
	scale = application_get_scale ();
	_tmp0_ = cairo_get_target (ctx);
	_tmp1_ = cairo_create (_tmp0_);
	_cairo_destroy0 (self->priv->wide_black_ctx);
	self->priv->wide_black_ctx = _tmp1_;
	_tmp2_ = self->priv->wide_black_ctx;
	set_source_color_from_string (_tmp2_, "#000");
	_tmp3_ = self->priv->wide_black_ctx;
	cairo_set_line_width (_tmp3_, 1 * scale);
	_tmp4_ = cairo_get_target (ctx);
	_tmp5_ = cairo_create (_tmp4_);
	_cairo_destroy0 (self->priv->wide_white_ctx);
	self->priv->wide_white_ctx = _tmp5_;
	_tmp6_ = self->priv->wide_white_ctx;
	set_source_color_from_string (_tmp6_, "#FFF");
	_tmp7_ = self->priv->wide_white_ctx;
	cairo_set_line_width (_tmp7_, 1 * scale);
	_tmp8_ = cairo_get_target (ctx);
	_tmp9_ = cairo_create (_tmp8_);
	_cairo_destroy0 (self->priv->thin_white_ctx);
	self->priv->thin_white_ctx = _tmp9_;
	_tmp10_ = self->priv->thin_white_ctx;
	set_source_color_from_string (_tmp10_, "#FFF");
	_tmp11_ = self->priv->thin_white_ctx;
	cairo_set_line_width (_tmp11_, 0.5 * scale);
	_tmp12_ = cairo_get_target (ctx);
	_tmp13_ = cairo_create (_tmp12_);
	_cairo_destroy0 (self->priv->text_ctx);
	self->priv->text_ctx = _tmp13_;
	_tmp14_ = self->priv->text_ctx;
	cairo_select_font_face (_tmp14_, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	_tmp15_ = self->priv->text_ctx;
	cairo_set_font_size (_tmp15_, 10.0 * scale);
}

static void
editing_tools_crop_tool_on_resized_pixbuf (EditingToolsCropTool* self,
                                           Dimensions* old_dim,
                                           GdkPixbuf* scaled,
                                           GdkRectangle* scaled_position)
{
	Dimensions new_dim = {0};
	Dimensions _tmp0_ = {0};
	Dimensions uncropped_dim = {0};
	EditingToolsPhotoCanvas* _tmp1_;
	Photo* _tmp2_;
	Photo* _tmp3_;
	Dimensions _tmp4_ = {0};
	Dimensions _tmp5_;
	Box crop = {0};
	Dimensions _tmp6_;
	Dimensions _tmp7_;
	Box _tmp8_ = {0};
	Dimensions _tmp9_;
	Dimensions _tmp10_;
	Box _tmp11_ = {0};
	cairo_surface_t* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	cairo_surface_t* _tmp17_;
	cairo_t* ctx = NULL;
	cairo_surface_t* _tmp18_;
	cairo_t* _tmp19_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (old_dim != NULL);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (scaled, gdk_pixbuf_get_type ()));
	g_return_if_fail (scaled_position != NULL);
	dimensions_for_pixbuf (scaled, &_tmp0_);
	new_dim = _tmp0_;
	_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp2_ = editing_tools_photo_canvas_get_photo (_tmp1_);
	_tmp3_ = _tmp2_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_CROP, &_tmp4_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp3_);
	uncropped_dim = _tmp5_;
	_tmp6_ = *old_dim;
	_tmp7_ = uncropped_dim;
	box_get_scaled_similar (&self->priv->scaled_crop, &_tmp6_, &_tmp7_, &_tmp8_);
	crop = _tmp8_;
	_tmp9_ = uncropped_dim;
	_tmp10_ = new_dim;
	box_get_scaled_similar (&crop, &_tmp9_, &_tmp10_, &_tmp11_);
	self->priv->scaled_crop = _tmp11_;
	_tmp12_ = self->priv->crop_surface;
	if (_tmp12_ != NULL) {
		_cairo_surface_destroy0 (self->priv->crop_surface);
		self->priv->crop_surface = NULL;
	}
	_tmp13_ = gdk_pixbuf_get_width (scaled);
	_tmp14_ = _tmp13_;
	_tmp15_ = gdk_pixbuf_get_height (scaled);
	_tmp16_ = _tmp15_;
	_tmp17_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, _tmp14_, _tmp16_);
	_cairo_surface_destroy0 (self->priv->crop_surface);
	self->priv->crop_surface = _tmp17_;
	_tmp18_ = self->priv->crop_surface;
	_tmp19_ = cairo_create (_tmp18_);
	ctx = _tmp19_;
	cairo_set_source_rgba (ctx, 0.0, 0.0, 0.0, 1.0);
	cairo_paint (ctx);
	_cairo_destroy0 (ctx);
}

static void
editing_tools_crop_tool_real_on_left_click (EditingToolsEditingTool* base,
                                            gint x,
                                            gint y)
{
	EditingToolsCropTool * self;
	GdkRectangle scaled_pixbuf_pos = {0};
	EditingToolsPhotoCanvas* _tmp0_;
	GdkRectangle _tmp1_ = {0};
	Box offset_scaled_crop = {0};
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	Box _tmp4_ = {0};
	gint xmul = 0;
	gint ymul = 0;
	GdkRectangle _tmp5_;
	GdkRectangle _tmp6_;
	EditingToolsPhotoCanvas* _tmp7_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp0_, &_tmp1_);
	scaled_pixbuf_pos = _tmp1_;
	_tmp2_ = scaled_pixbuf_pos;
	_tmp3_ = scaled_pixbuf_pos;
	box_get_offset (&self->priv->scaled_crop, _tmp2_.x, _tmp3_.y, &_tmp4_);
	offset_scaled_crop = _tmp4_;
	xmul = (gint) lround (x * application_get_scale ());
	ymul = (gint) lround (y * application_get_scale ());
	self->priv->in_manipulation = box_approx_location (&offset_scaled_crop, xmul, ymul);
	_tmp5_ = scaled_pixbuf_pos;
	self->priv->last_grab_x = xmul - _tmp5_.x;
	_tmp6_ = scaled_pixbuf_pos;
	self->priv->last_grab_y = ymul - _tmp6_.y;
	_tmp7_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp7_);
}

static void
editing_tools_crop_tool_real_on_left_released (EditingToolsEditingTool* base,
                                               gint x,
                                               gint y)
{
	EditingToolsCropTool * self;
	EditingToolsPhotoCanvas* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	if (self->priv->in_manipulation == BOX_LOCATION_OUTSIDE) {
		return;
	}
	self->priv->in_manipulation = BOX_LOCATION_OUTSIDE;
	self->priv->last_grab_x = -1;
	self->priv->last_grab_y = -1;
	editing_tools_crop_tool_update_cursor (self, x, y);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp0_);
}

static void
editing_tools_crop_tool_real_on_motion (EditingToolsEditingTool* base,
                                        gint x,
                                        gint y,
                                        GdkModifierType mask)
{
	EditingToolsCropTool * self;
	EditingToolsPhotoCanvas* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	if (self->priv->in_manipulation != BOX_LOCATION_OUTSIDE) {
		editing_tools_crop_tool_on_canvas_manipulation (self, (gint) lround (x * application_get_scale ()), (gint) lround (y * application_get_scale ()));
	}
	editing_tools_crop_tool_update_cursor (self, x, y);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp0_);
}

static void
editing_tools_crop_tool_real_paint (EditingToolsEditingTool* base,
                                    cairo_t* default_ctx)
{
	EditingToolsCropTool * self;
	gdouble scale = 0.0;
	gint w = 0;
	EditingToolsPhotoCanvas* _tmp0_;
	GdkWindow* _tmp1_;
	GdkWindow* _tmp2_;
	gint _tmp3_;
	gint h = 0;
	EditingToolsPhotoCanvas* _tmp4_;
	GdkWindow* _tmp5_;
	GdkWindow* _tmp6_;
	gint _tmp7_;
	cairo_t* ctx = NULL;
	cairo_surface_t* _tmp8_;
	cairo_t* _tmp9_;
	Box _tmp10_;
	Box _tmp11_;
	EditingToolsPhotoCanvas* _tmp12_;
	cairo_surface_t* _tmp13_;
	Box _tmp14_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	g_return_if_fail (default_ctx != NULL);
	scale = application_get_scale ();
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp1_ = editing_tools_photo_canvas_get_drawing_window (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gdk_window_get_width (_tmp2_);
	_g_object_unref0 (_tmp2_);
	w = _tmp3_;
	_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp5_ = editing_tools_photo_canvas_get_drawing_window (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = gdk_window_get_height (_tmp6_);
	_g_object_unref0 (_tmp6_);
	h = _tmp7_;
	cairo_set_source_rgba (default_ctx, 0.0, 0.0, 0.0, 1.0);
	cairo_rectangle (default_ctx, (gdouble) 0, (gdouble) 0, w * scale, h * scale);
	cairo_fill (default_ctx);
	cairo_paint (default_ctx);
	_tmp8_ = self->priv->crop_surface;
	_tmp9_ = cairo_create (_tmp8_);
	ctx = _tmp9_;
	cairo_set_operator (ctx, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_rgba (ctx, 0.0, 0.0, 0.0, 0.5);
	cairo_paint (ctx);
	cairo_set_source_rgba (ctx, 0.0, 0.0, 0.0, 0.0);
	_tmp10_ = self->priv->scaled_crop;
	_tmp11_ = self->priv->scaled_crop;
	cairo_rectangle (ctx, (gdouble) _tmp10_.left, (gdouble) _tmp11_.top, (gdouble) box_get_width (&self->priv->scaled_crop), (gdouble) box_get_height (&self->priv->scaled_crop));
	cairo_fill (ctx);
	_tmp12_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp13_ = self->priv->crop_surface;
	editing_tools_photo_canvas_paint_surface (_tmp12_, _tmp13_, TRUE);
	_tmp14_ = self->priv->scaled_crop;
	editing_tools_crop_tool_paint_crop_tool (self, &_tmp14_);
	_cairo_destroy0 (ctx);
}

static void
editing_tools_crop_tool_on_crop_ok (EditingToolsCropTool* self)
{
	ConfigFacade* _tmp0_;
	ConfigFacade* _tmp1_;
	EditingToolsCropToolCropToolWindow* _tmp2_;
	GtkComboBox* _tmp3_;
	ConfigFacade* _tmp4_;
	ConfigFacade* _tmp5_;
	ConfigFacade* _tmp6_;
	ConfigFacade* _tmp7_;
	Box crop = {0};
	EditingToolsPhotoCanvas* _tmp8_;
	GdkRectangle _tmp9_ = {0};
	Dimensions _tmp10_ = {0};
	EditingToolsPhotoCanvas* _tmp11_;
	Photo* _tmp12_;
	Photo* _tmp13_;
	Dimensions _tmp14_ = {0};
	Box _tmp15_ = {0};
	Box _tmp16_;
	GdkPixbuf* cropped = NULL;
	EditingToolsPhotoCanvas* _tmp17_;
	GdkPixbuf* _tmp18_;
	GdkPixbuf* _tmp19_;
	Box _tmp20_;
	Box _tmp21_;
	GdkPixbuf* _tmp22_;
	GdkPixbuf* _tmp23_;
	EditingToolsPhotoCanvas* _tmp24_;
	Photo* _tmp25_;
	Photo* _tmp26_;
	Box _tmp27_;
	CropCommand* _tmp28_;
	CropCommand* _tmp29_;
	Dimensions _tmp30_ = {0};
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	_tmp0_ = config_facade_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->crop_tool_window;
	_tmp3_ = _tmp2_->constraint_combo;
	configuration_facade_set_last_crop_menu_choice (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), gtk_combo_box_get_active (_tmp3_));
	_g_object_unref0 (_tmp1_);
	_tmp4_ = config_facade_get_instance ();
	_tmp5_ = _tmp4_;
	configuration_facade_set_last_crop_width (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), self->priv->custom_width);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = config_facade_get_instance ();
	_tmp7_ = _tmp6_;
	configuration_facade_set_last_crop_height (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), self->priv->custom_height);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp8_, &_tmp9_);
	dimensions_for_rectangle (&_tmp9_, &_tmp10_);
	_tmp11_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp12_ = editing_tools_photo_canvas_get_photo (_tmp11_);
	_tmp13_ = _tmp12_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_CROP, &_tmp14_);
	box_get_scaled_similar (&self->priv->scaled_crop, &_tmp10_, &_tmp14_, &_tmp15_);
	_tmp16_ = _tmp15_;
	_g_object_unref0 (_tmp13_);
	crop = _tmp16_;
	_tmp17_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp18_ = editing_tools_photo_canvas_get_scaled_pixbuf (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = self->priv->scaled_crop;
	_tmp21_ = self->priv->scaled_crop;
	_tmp22_ = gdk_pixbuf_new_subpixbuf (_tmp19_, _tmp20_.left, _tmp21_.top, box_get_width (&self->priv->scaled_crop), box_get_height (&self->priv->scaled_crop));
	_tmp23_ = _tmp22_;
	_g_object_unref0 (_tmp19_);
	cropped = _tmp23_;
	_tmp24_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp25_ = editing_tools_photo_canvas_get_photo (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp27_ = crop;
	_tmp28_ = crop_command_new (_tmp26_, &_tmp27_, RESOURCES_CROP_LABEL, RESOURCES_CROP_TOOLTIP);
	_tmp29_ = _tmp28_;
	box_get_dimensions (&crop, &_tmp30_);
	g_signal_emit (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_APPLIED_SIGNAL], 0, G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, TYPE_COMMAND, Command), cropped, &_tmp30_, TRUE);
	_g_object_unref0 (_tmp29_);
	_g_object_unref0 (_tmp26_);
	_g_object_unref0 (cropped);
}

static void
editing_tools_crop_tool_update_cursor (EditingToolsCropTool* self,
                                       gint x,
                                       gint y)
{
	GdkRectangle scaled_pos = {0};
	EditingToolsPhotoCanvas* _tmp0_;
	GdkRectangle _tmp1_ = {0};
	Box offset_scaled_crop = {0};
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	Box _tmp4_ = {0};
	GdkCursorType cursor_type = 0;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp0_, &_tmp1_);
	scaled_pos = _tmp1_;
	_tmp2_ = scaled_pos;
	_tmp3_ = scaled_pos;
	box_get_offset (&self->priv->scaled_crop, _tmp2_.x, _tmp3_.y, &_tmp4_);
	offset_scaled_crop = _tmp4_;
	cursor_type = GDK_LEFT_PTR;
	switch (box_approx_location (&offset_scaled_crop, (gint) lround (x * application_get_scale ()), (gint) lround (y * application_get_scale ()))) {
		case BOX_LOCATION_LEFT_SIDE:
		{
			cursor_type = GDK_LEFT_SIDE;
			break;
		}
		case BOX_LOCATION_TOP_SIDE:
		{
			cursor_type = GDK_TOP_SIDE;
			break;
		}
		case BOX_LOCATION_RIGHT_SIDE:
		{
			cursor_type = GDK_RIGHT_SIDE;
			break;
		}
		case BOX_LOCATION_BOTTOM_SIDE:
		{
			cursor_type = GDK_BOTTOM_SIDE;
			break;
		}
		case BOX_LOCATION_TOP_LEFT:
		{
			cursor_type = GDK_TOP_LEFT_CORNER;
			break;
		}
		case BOX_LOCATION_BOTTOM_LEFT:
		{
			cursor_type = GDK_BOTTOM_LEFT_CORNER;
			break;
		}
		case BOX_LOCATION_TOP_RIGHT:
		{
			cursor_type = GDK_TOP_RIGHT_CORNER;
			break;
		}
		case BOX_LOCATION_BOTTOM_RIGHT:
		{
			cursor_type = GDK_BOTTOM_RIGHT_CORNER;
			break;
		}
		case BOX_LOCATION_INSIDE:
		{
			cursor_type = GDK_FLEUR;
			break;
		}
		default:
		{
			break;
		}
	}
	if (cursor_type != self->priv->current_cursor_type) {
		EditingToolsPhotoCanvas* _tmp5_;
		_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_set_cursor (_tmp5_, cursor_type);
		self->priv->current_cursor_type = cursor_type;
	}
}

static gint
editing_tools_crop_tool_eval_radial_line (EditingToolsCropTool* self,
                                          gdouble center_x,
                                          gdouble center_y,
                                          gdouble bounds_x,
                                          gdouble bounds_y,
                                          gdouble user_x)
{
	gdouble decision_slope = 0.0;
	gdouble decision_intercept = 0.0;
	gint result;
	g_return_val_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self), -1);
	decision_slope = (bounds_y - center_y) / (bounds_x - center_x);
	decision_intercept = bounds_y - (decision_slope * bounds_x);
	result = (gint) ((decision_slope * user_x) + decision_intercept);
	return result;
}

static void
editing_tools_crop_tool_get_photo_dimensions (EditingToolsCropTool* self,
                                              Dimensions* result)
{
	Dimensions photo_dims = {0};
	EditingToolsPhotoCanvas* _tmp0_;
	Photo* _tmp1_;
	Photo* _tmp2_;
	Dimensions _tmp3_ = {0};
	Dimensions _tmp4_;
	Dimensions surface_dims = {0};
	EditingToolsPhotoCanvas* _tmp5_;
	Dimensions _tmp6_ = {0};
	gdouble scale_factor = 0.0;
	Dimensions _tmp7_;
	Dimensions _tmp8_;
	Dimensions _tmp9_;
	Dimensions _tmp10_;
	EditingToolsPhotoCanvas* _tmp11_;
	Photo* _tmp12_;
	Photo* _tmp13_;
	Dimensions _tmp14_ = {0};
	Dimensions _tmp15_;
	Dimensions _tmp16_;
	Dimensions _tmp17_ = {0};
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp1_ = editing_tools_photo_canvas_get_photo (_tmp0_);
	_tmp2_ = _tmp1_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_CROP, &_tmp3_);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp2_);
	photo_dims = _tmp4_;
	_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_get_surface_dim (_tmp5_, &_tmp6_);
	surface_dims = _tmp6_;
	_tmp7_ = surface_dims;
	_tmp8_ = photo_dims;
	_tmp9_ = surface_dims;
	_tmp10_ = photo_dims;
	scale_factor = MIN (((gdouble) _tmp7_.width) / _tmp8_.width, ((gdouble) _tmp9_.height) / _tmp10_.height);
	scale_factor = MIN (scale_factor, 1.0);
	_tmp11_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp12_ = editing_tools_photo_canvas_get_photo (_tmp11_);
	_tmp13_ = _tmp12_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_CROP | PHOTO_EXCEPTION_STRAIGHTEN, &_tmp14_);
	photo_dims = _tmp14_;
	_g_object_unref0 (_tmp13_);
	_tmp15_ = photo_dims;
	_tmp16_ = photo_dims;
	_tmp17_.width = (gint) (_tmp15_.width * scale_factor);
	_tmp17_.height = (gint) (_tmp16_.height * scale_factor);
	*result = _tmp17_;
	return;
}

static gboolean
_box_equal (const Box * s1,
            const Box * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (s1->left != s2->left) {
		return FALSE;
	}
	if (s1->top != s2->top) {
		return FALSE;
	}
	if (s1->right != s2->right) {
		return FALSE;
	}
	if (s1->bottom != s2->bottom) {
		return FALSE;
	}
	return TRUE;
}

static gboolean
editing_tools_crop_tool_on_canvas_manipulation (EditingToolsCropTool* self,
                                                gint x,
                                                gint y)
{
	GdkRectangle scaled_pos = {0};
	EditingToolsPhotoCanvas* _tmp0_;
	GdkRectangle _tmp1_ = {0};
	GdkRectangle _tmp2_;
	GdkRectangle _tmp5_;
	gint left = 0;
	Box _tmp8_;
	gint top = 0;
	Box _tmp9_;
	gint right = 0;
	Box _tmp10_;
	gint bottom = 0;
	Box _tmp11_;
	gint center_x = 0;
	gint center_y = 0;
	gint width = 0;
	gint height = 0;
	Dimensions photo_dims = {0};
	Dimensions _tmp16_ = {0};
	gdouble angle = 0.0;
	EditingToolsPhotoCanvas* _tmp17_;
	Photo* _tmp18_;
	Photo* _tmp19_;
	gdouble _tmp20_ = 0.0;
	Box new_crop = {0};
	Box _tmp36_;
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self), FALSE);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp0_, &_tmp1_);
	scaled_pos = _tmp1_;
	_tmp2_ = scaled_pos;
	x = x - _tmp2_.x;
	if (x < 0) {
		x = 0;
	} else {
		GdkRectangle _tmp3_;
		_tmp3_ = scaled_pos;
		if (x >= _tmp3_.width) {
			GdkRectangle _tmp4_;
			_tmp4_ = scaled_pos;
			x = _tmp4_.width - 1;
		}
	}
	_tmp5_ = scaled_pos;
	y = y - _tmp5_.y;
	if (y < 0) {
		y = 0;
	} else {
		GdkRectangle _tmp6_;
		_tmp6_ = scaled_pos;
		if (y >= _tmp6_.height) {
			GdkRectangle _tmp7_;
			_tmp7_ = scaled_pos;
			y = _tmp7_.height - 1;
		}
	}
	_tmp8_ = self->priv->scaled_crop;
	left = _tmp8_.left;
	_tmp9_ = self->priv->scaled_crop;
	top = _tmp9_.top;
	_tmp10_ = self->priv->scaled_crop;
	right = _tmp10_.right;
	_tmp11_ = self->priv->scaled_crop;
	bottom = _tmp11_.bottom;
	center_x = (left + right) / 2;
	center_y = (top + bottom) / 2;
	switch (self->priv->in_manipulation) {
		case BOX_LOCATION_LEFT_SIDE:
		{
			left = x;
			if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) != EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
				gfloat new_height = 0.0F;
				new_height = ((gfloat) (right - left)) / editing_tools_crop_tool_get_constraint_aspect_ratio (self);
				bottom = top + ((gint) new_height);
			}
			break;
		}
		case BOX_LOCATION_TOP_SIDE:
		{
			top = y;
			if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) != EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
				gfloat new_width = 0.0F;
				new_width = ((gfloat) (bottom - top)) * editing_tools_crop_tool_get_constraint_aspect_ratio (self);
				right = left + ((gint) new_width);
			}
			break;
		}
		case BOX_LOCATION_RIGHT_SIDE:
		{
			right = x;
			if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) != EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
				gfloat new_height = 0.0F;
				new_height = ((gfloat) (right - left)) / editing_tools_crop_tool_get_constraint_aspect_ratio (self);
				bottom = top + ((gint) new_height);
			}
			break;
		}
		case BOX_LOCATION_BOTTOM_SIDE:
		{
			bottom = y;
			if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) != EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
				gfloat new_width = 0.0F;
				new_width = ((gfloat) (bottom - top)) * editing_tools_crop_tool_get_constraint_aspect_ratio (self);
				right = left + ((gint) new_width);
			}
			break;
		}
		case BOX_LOCATION_TOP_LEFT:
		{
			if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) == EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
				top = y;
				left = x;
			} else {
				if (y < editing_tools_crop_tool_eval_radial_line (self, (gdouble) center_x, (gdouble) center_y, (gdouble) left, (gdouble) top, (gdouble) x)) {
					gfloat new_width = 0.0F;
					top = y;
					new_width = ((gfloat) (bottom - top)) * editing_tools_crop_tool_get_constraint_aspect_ratio (self);
					left = right - ((gint) new_width);
				} else {
					gfloat new_height = 0.0F;
					left = x;
					new_height = ((gfloat) (right - left)) / editing_tools_crop_tool_get_constraint_aspect_ratio (self);
					top = bottom - ((gint) new_height);
				}
			}
			break;
		}
		case BOX_LOCATION_BOTTOM_LEFT:
		{
			if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) == EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
				bottom = y;
				left = x;
			} else {
				if (y < editing_tools_crop_tool_eval_radial_line (self, (gdouble) center_x, (gdouble) center_y, (gdouble) left, (gdouble) bottom, (gdouble) x)) {
					gfloat new_height = 0.0F;
					left = x;
					new_height = ((gfloat) (right - left)) / editing_tools_crop_tool_get_constraint_aspect_ratio (self);
					bottom = top + ((gint) new_height);
				} else {
					gfloat new_width = 0.0F;
					bottom = y;
					new_width = ((gfloat) (bottom - top)) * editing_tools_crop_tool_get_constraint_aspect_ratio (self);
					left = right - ((gint) new_width);
				}
			}
			break;
		}
		case BOX_LOCATION_TOP_RIGHT:
		{
			if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) == EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
				top = y;
				right = x;
			} else {
				if (y < editing_tools_crop_tool_eval_radial_line (self, (gdouble) center_x, (gdouble) center_y, (gdouble) right, (gdouble) top, (gdouble) x)) {
					gfloat new_width = 0.0F;
					top = y;
					new_width = ((gfloat) (bottom - top)) * editing_tools_crop_tool_get_constraint_aspect_ratio (self);
					right = left + ((gint) new_width);
				} else {
					gfloat new_height = 0.0F;
					right = x;
					new_height = ((gfloat) (right - left)) / editing_tools_crop_tool_get_constraint_aspect_ratio (self);
					top = bottom - ((gint) new_height);
				}
			}
			break;
		}
		case BOX_LOCATION_BOTTOM_RIGHT:
		{
			if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) == EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
				bottom = y;
				right = x;
			} else {
				if (y < editing_tools_crop_tool_eval_radial_line (self, (gdouble) center_x, (gdouble) center_y, (gdouble) right, (gdouble) bottom, (gdouble) x)) {
					gfloat new_height = 0.0F;
					right = x;
					new_height = ((gfloat) (right - left)) / editing_tools_crop_tool_get_constraint_aspect_ratio (self);
					bottom = top + ((gint) new_height);
				} else {
					gfloat new_width = 0.0F;
					bottom = y;
					new_width = ((gfloat) (bottom - top)) * editing_tools_crop_tool_get_constraint_aspect_ratio (self);
					right = left + ((gint) new_width);
				}
			}
			break;
		}
		case BOX_LOCATION_INSIDE:
		{
			gint delta_x = 0;
			gint delta_y = 0;
			gint width = 0;
			gint height = 0;
			GdkRectangle _tmp12_;
			GdkRectangle _tmp14_;
			gint adj_width = 0;
			gint adj_height = 0;
			_vala_assert (self->priv->last_grab_x >= 0, "last_grab_x >= 0");
			_vala_assert (self->priv->last_grab_y >= 0, "last_grab_y >= 0");
			delta_x = x - self->priv->last_grab_x;
			delta_y = y - self->priv->last_grab_y;
			self->priv->last_grab_x = x;
			self->priv->last_grab_y = y;
			width = (right - left) + 1;
			height = (bottom - top) + 1;
			left += delta_x;
			top += delta_y;
			right += delta_x;
			bottom += delta_y;
			if (left < 0) {
				left = 0;
			}
			if (top < 0) {
				top = 0;
			}
			_tmp12_ = scaled_pos;
			if (right >= _tmp12_.width) {
				GdkRectangle _tmp13_;
				_tmp13_ = scaled_pos;
				right = _tmp13_.width - 1;
			}
			_tmp14_ = scaled_pos;
			if (bottom >= _tmp14_.height) {
				GdkRectangle _tmp15_;
				_tmp15_ = scaled_pos;
				bottom = _tmp15_.height - 1;
			}
			adj_width = (right - left) + 1;
			adj_height = (bottom - top) + 1;
			if (adj_width != width) {
				if (delta_x < 0) {
					right = (left + width) - 1;
				} else {
					left = (right - width) + 1;
				}
			}
			if (adj_height != height) {
				if (delta_y < 0) {
					bottom = (top + height) - 1;
				} else {
					top = (bottom - height) + 1;
				}
			}
			break;
		}
		default:
		{
			result = FALSE;
			return result;
		}
	}
	width = (right - left) + 1;
	height = (bottom - top) + 1;
	editing_tools_crop_tool_get_photo_dimensions (self, &_tmp16_);
	photo_dims = _tmp16_;
	_tmp17_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp18_ = editing_tools_photo_canvas_get_photo (_tmp17_);
	_tmp19_ = _tmp18_;
	photo_get_straighten (_tmp19_, &_tmp20_);
	angle = _tmp20_;
	_g_object_unref0 (_tmp19_);
	if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) == EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
		Box _tmp21_ = {0};
		Dimensions _tmp22_;
		Dimensions _tmp23_;
		Box _tmp24_ = {0};
		width = (right - left) + 1;
		height = (bottom - top) + 1;
		switch (self->priv->in_manipulation) {
			case BOX_LOCATION_LEFT_SIDE:
			case BOX_LOCATION_TOP_LEFT:
			case BOX_LOCATION_BOTTOM_LEFT:
			{
				if (width < EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE) {
					left = right - EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE;
				}
				break;
			}
			case BOX_LOCATION_RIGHT_SIDE:
			case BOX_LOCATION_TOP_RIGHT:
			case BOX_LOCATION_BOTTOM_RIGHT:
			{
				if (width < EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE) {
					right = left + EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE;
				}
				break;
			}
			default:
			{
				break;
			}
		}
		switch (self->priv->in_manipulation) {
			case BOX_LOCATION_TOP_SIDE:
			case BOX_LOCATION_TOP_LEFT:
			case BOX_LOCATION_TOP_RIGHT:
			{
				if (height < EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE) {
					top = bottom - EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE;
				}
				break;
			}
			case BOX_LOCATION_BOTTOM_SIDE:
			case BOX_LOCATION_BOTTOM_LEFT:
			case BOX_LOCATION_BOTTOM_RIGHT:
			{
				if (height < EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE) {
					bottom = top + EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE;
				}
				break;
			}
			default:
			{
				break;
			}
		}
		box_init (&_tmp21_, left, top, right, bottom);
		_tmp22_ = photo_dims;
		_tmp23_ = photo_dims;
		clamp_inside_rotated_image (&_tmp21_, _tmp22_.width, _tmp23_.height, angle, self->priv->in_manipulation == BOX_LOCATION_INSIDE, &_tmp24_);
		new_crop = _tmp24_;
	} else {
		Box adjusted = {0};
		Box _tmp25_;
		Dimensions _tmp26_;
		Dimensions _tmp27_;
		Box _tmp28_ = {0};
		gboolean _tmp29_ = FALSE;
		gboolean _tmp30_ = FALSE;
		Box _tmp31_;
		Box _tmp32_;
		box_init (&new_crop, left, top, right, bottom);
		_tmp25_ = new_crop;
		_tmp26_ = photo_dims;
		_tmp27_ = photo_dims;
		clamp_inside_rotated_image (&_tmp25_, _tmp26_.width, _tmp27_.height, angle, self->priv->in_manipulation == BOX_LOCATION_INSIDE, &_tmp28_);
		adjusted = _tmp28_;
		_tmp31_ = adjusted;
		_tmp32_ = new_crop;
		if (_box_equal (&_tmp31_, &_tmp32_) != TRUE) {
			_tmp30_ = TRUE;
		} else {
			_tmp30_ = width < EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE;
		}
		if (_tmp30_) {
			_tmp29_ = TRUE;
		} else {
			_tmp29_ = height < EDITING_TOOLS_CROP_TOOL_CROP_MIN_SIZE;
		}
		if (_tmp29_) {
			Box _tmp33_;
			_tmp33_ = self->priv->scaled_crop;
			new_crop = _tmp33_;
		}
	}
	if (self->priv->in_manipulation != BOX_LOCATION_INSIDE) {
		Box _tmp34_;
		_tmp34_ = new_crop;
		editing_tools_crop_tool_crop_resized (self, &_tmp34_);
	} else {
		Box _tmp35_;
		_tmp35_ = new_crop;
		editing_tools_crop_tool_crop_moved (self, &_tmp35_);
	}
	_tmp36_ = new_crop;
	self->priv->scaled_crop = _tmp36_;
	if (editing_tools_crop_tool_get_constraint_aspect_ratio (self) == EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO) {
		self->priv->custom_init_width = box_get_width (&self->priv->scaled_crop);
		self->priv->custom_init_height = box_get_height (&self->priv->scaled_crop);
		self->priv->custom_aspect_ratio = ((gfloat) self->priv->custom_init_width) / ((gfloat) self->priv->custom_init_height);
	}
	result = FALSE;
	return result;
}

static void
editing_tools_crop_tool_crop_resized (EditingToolsCropTool* self,
                                      Box* new_crop)
{
	Box _tmp0_;
	EditingToolsPhotoCanvas* _tmp1_;
	Box _tmp2_;
	Box horizontal = {0};
	gboolean horizontal_enlarged = FALSE;
	Box vertical = {0};
	gboolean vertical_enlarged = FALSE;
	BoxComplements complements = 0;
	Box _tmp3_;
	Box _tmp4_ = {0};
	gboolean _tmp5_ = FALSE;
	Box _tmp6_ = {0};
	gboolean _tmp7_ = FALSE;
	BoxComplements _tmp8_;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp12_ = FALSE;
	Box _tmp15_;
	EditingToolsPhotoCanvas* _tmp16_;
	Box _tmp17_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (new_crop != NULL);
	_tmp0_ = *new_crop;
	if (box_equals (&self->priv->scaled_crop, &_tmp0_)) {
		return;
	}
	_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp2_ = self->priv->scaled_crop;
	editing_tools_photo_canvas_invalidate_area (_tmp1_, &_tmp2_);
	_tmp3_ = *new_crop;
	_tmp8_ = box_resized_complements (&self->priv->scaled_crop, &_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
	horizontal = _tmp4_;
	horizontal_enlarged = _tmp5_;
	vertical = _tmp6_;
	vertical_enlarged = _tmp7_;
	complements = _tmp8_;
	_vala_assert (complements != BOX_COMPLEMENTS_NONE, "complements != BoxComplements.NONE");
	if (complements == BOX_COMPLEMENTS_HORIZONTAL) {
		_tmp9_ = TRUE;
	} else {
		_tmp9_ = complements == BOX_COMPLEMENTS_BOTH;
	}
	if (_tmp9_) {
		gdouble _tmp10_ = 0.0;
		Box _tmp11_;
		if (horizontal_enlarged) {
			_tmp10_ = 0.0;
		} else {
			_tmp10_ = 0.5;
		}
		_tmp11_ = horizontal;
		editing_tools_crop_tool_set_area_alpha (self, &_tmp11_, _tmp10_);
	}
	if (complements == BOX_COMPLEMENTS_VERTICAL) {
		_tmp12_ = TRUE;
	} else {
		_tmp12_ = complements == BOX_COMPLEMENTS_BOTH;
	}
	if (_tmp12_) {
		gdouble _tmp13_ = 0.0;
		Box _tmp14_;
		if (vertical_enlarged) {
			_tmp13_ = 0.0;
		} else {
			_tmp13_ = 0.5;
		}
		_tmp14_ = vertical;
		editing_tools_crop_tool_set_area_alpha (self, &_tmp14_, _tmp13_);
	}
	_tmp15_ = *new_crop;
	editing_tools_crop_tool_paint_crop_tool (self, &_tmp15_);
	_tmp16_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp17_ = *new_crop;
	editing_tools_photo_canvas_invalidate_area (_tmp16_, &_tmp17_);
}

static void
editing_tools_crop_tool_crop_moved (EditingToolsCropTool* self,
                                    Box* new_crop)
{
	Box _tmp0_;
	EditingToolsPhotoCanvas* _tmp1_;
	Box _tmp2_;
	Box _tmp3_;
	Box _tmp4_;
	Box _tmp5_;
	EditingToolsPhotoCanvas* _tmp6_;
	Box _tmp7_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (new_crop != NULL);
	_tmp0_ = *new_crop;
	if (box_equals (&self->priv->scaled_crop, &_tmp0_)) {
		return;
	}
	_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp2_ = self->priv->scaled_crop;
	editing_tools_photo_canvas_invalidate_area (_tmp1_, &_tmp2_);
	_tmp3_ = self->priv->scaled_crop;
	editing_tools_crop_tool_set_area_alpha (self, &_tmp3_, 0.5);
	_tmp4_ = *new_crop;
	editing_tools_crop_tool_set_area_alpha (self, &_tmp4_, 0.0);
	_tmp5_ = *new_crop;
	editing_tools_crop_tool_paint_crop_tool (self, &_tmp5_);
	_tmp6_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp7_ = *new_crop;
	editing_tools_photo_canvas_invalidate_area (_tmp6_, &_tmp7_);
}

static void
editing_tools_crop_tool_set_area_alpha (EditingToolsCropTool* self,
                                        Box* area,
                                        gdouble alpha)
{
	cairo_t* ctx = NULL;
	cairo_surface_t* _tmp0_;
	cairo_t* _tmp1_;
	Box _tmp2_;
	Box _tmp3_;
	EditingToolsPhotoCanvas* _tmp4_;
	cairo_surface_t* _tmp5_;
	Box _tmp6_;
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (area != NULL);
	_tmp0_ = self->priv->crop_surface;
	_tmp1_ = cairo_create (_tmp0_);
	ctx = _tmp1_;
	cairo_set_operator (ctx, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_rgba (ctx, 0.0, 0.0, 0.0, alpha);
	_tmp2_ = *area;
	_tmp3_ = *area;
	cairo_rectangle (ctx, (gdouble) _tmp2_.left, (gdouble) _tmp3_.top, (gdouble) box_get_width (area), (gdouble) box_get_height (area));
	cairo_fill (ctx);
	_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp5_ = self->priv->crop_surface;
	_tmp6_ = *area;
	editing_tools_photo_canvas_paint_surface_area (_tmp4_, _tmp5_, &_tmp6_, TRUE);
	_cairo_destroy0 (ctx);
}

static void
editing_tools_crop_tool_paint_crop_tool (EditingToolsCropTool* self,
                                         Box* crop)
{
	EditingToolsPhotoCanvas* _tmp38_;
	cairo_t* _tmp39_;
	Box _tmp40_;
	EditingToolsPhotoCanvas* _tmp41_;
	cairo_t* _tmp42_;
	Box _tmp43_ = {0};
	EditingToolsPhotoCanvas* _tmp44_;
	cairo_t* _tmp45_;
	Box _tmp46_ = {0};
	g_return_if_fail (EDITING_TOOLS_IS_CROP_TOOL (self));
	g_return_if_fail (crop != NULL);
	if (self->priv->in_manipulation != BOX_LOCATION_OUTSIDE) {
		gint one_third_x = 0;
		gint one_third_y = 0;
		EditingToolsPhotoCanvas* _tmp0_;
		cairo_t* _tmp1_;
		Box _tmp2_;
		Box _tmp3_;
		EditingToolsPhotoCanvas* _tmp4_;
		cairo_t* _tmp5_;
		Box _tmp6_;
		Box _tmp7_;
		EditingToolsPhotoCanvas* _tmp8_;
		cairo_t* _tmp9_;
		Box _tmp10_;
		Box _tmp11_;
		EditingToolsPhotoCanvas* _tmp12_;
		cairo_t* _tmp13_;
		Box _tmp14_;
		Box _tmp15_;
		Box adj_crop = {0};
		EditingToolsPhotoCanvas* _tmp16_;
		GdkRectangle _tmp17_ = {0};
		Dimensions _tmp18_ = {0};
		EditingToolsPhotoCanvas* _tmp19_;
		Photo* _tmp20_;
		Photo* _tmp21_;
		Dimensions _tmp22_ = {0};
		Box _tmp23_ = {0};
		Box _tmp24_;
		gchar* text = NULL;
		gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		gchar* _tmp28_;
		gchar* _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		gchar* _tmp32_;
		gint x = 0;
		Box _tmp33_;
		gint y = 0;
		Box _tmp34_;
		EditingToolsPhotoCanvas* _tmp35_;
		cairo_t* _tmp36_;
		const gchar* _tmp37_;
		one_third_x = box_get_width (crop) / 3;
		one_third_y = box_get_height (crop) / 3;
		_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp1_ = self->priv->thin_white_ctx;
		_tmp2_ = *crop;
		_tmp3_ = *crop;
		editing_tools_photo_canvas_draw_horizontal_line (_tmp0_, _tmp1_, _tmp2_.left, _tmp3_.top + one_third_y, box_get_width (crop), TRUE);
		_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp5_ = self->priv->thin_white_ctx;
		_tmp6_ = *crop;
		_tmp7_ = *crop;
		editing_tools_photo_canvas_draw_horizontal_line (_tmp4_, _tmp5_, _tmp6_.left, _tmp7_.top + (one_third_y * 2), box_get_width (crop), TRUE);
		_tmp8_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp9_ = self->priv->thin_white_ctx;
		_tmp10_ = *crop;
		_tmp11_ = *crop;
		editing_tools_photo_canvas_draw_vertical_line (_tmp8_, _tmp9_, _tmp10_.left + one_third_x, _tmp11_.top, box_get_height (crop), TRUE);
		_tmp12_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp13_ = self->priv->thin_white_ctx;
		_tmp14_ = *crop;
		_tmp15_ = *crop;
		editing_tools_photo_canvas_draw_vertical_line (_tmp12_, _tmp13_, _tmp14_.left + (one_third_x * 2), _tmp15_.top, box_get_height (crop), TRUE);
		_tmp16_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp16_, &_tmp17_);
		dimensions_for_rectangle (&_tmp17_, &_tmp18_);
		_tmp19_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp20_ = editing_tools_photo_canvas_get_photo (_tmp19_);
		_tmp21_ = _tmp20_;
		media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_CROP, &_tmp22_);
		box_get_scaled_similar (&self->priv->scaled_crop, &_tmp18_, &_tmp22_, &_tmp23_);
		_tmp24_ = _tmp23_;
		_g_object_unref0 (_tmp21_);
		adj_crop = _tmp24_;
		_tmp25_ = g_strdup_printf ("%i", box_get_width (&adj_crop));
		_tmp26_ = _tmp25_;
		_tmp27_ = g_strconcat (_tmp26_, "x", NULL);
		_tmp28_ = _tmp27_;
		_tmp29_ = g_strdup_printf ("%i", box_get_height (&adj_crop));
		_tmp30_ = _tmp29_;
		_tmp31_ = g_strconcat (_tmp28_, _tmp30_, NULL);
		_tmp32_ = _tmp31_;
		_g_free0 (_tmp30_);
		_g_free0 (_tmp28_);
		_g_free0 (_tmp26_);
		text = _tmp32_;
		_tmp33_ = *crop;
		x = _tmp33_.left + (box_get_width (crop) / 2);
		_tmp34_ = *crop;
		y = _tmp34_.top + (box_get_height (crop) / 2);
		_tmp35_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp36_ = self->priv->text_ctx;
		_tmp37_ = text;
		editing_tools_photo_canvas_draw_text (_tmp35_, _tmp36_, _tmp37_, x, y, TRUE);
		_g_free0 (text);
	}
	_tmp38_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp39_ = self->priv->wide_black_ctx;
	_tmp40_ = *crop;
	editing_tools_photo_canvas_draw_box (_tmp38_, _tmp39_, &_tmp40_);
	_tmp41_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp42_ = self->priv->wide_white_ctx;
	box_get_reduced (crop, 1, &_tmp43_);
	editing_tools_photo_canvas_draw_box (_tmp41_, _tmp42_, &_tmp43_);
	_tmp44_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp45_ = self->priv->wide_white_ctx;
	box_get_reduced (crop, 2, &_tmp46_);
	editing_tools_photo_canvas_draw_box (_tmp44_, _tmp45_, &_tmp46_);
}

static EditingToolsCropToolConstraintDescription*
editing_tools_crop_tool_constraint_description_construct (GType object_type,
                                                          const gchar* new_name,
                                                          gint new_basis_width,
                                                          gint new_basis_height,
                                                          gboolean new_pivotable,
                                                          gfloat new_aspect_ratio)
{
	EditingToolsCropToolConstraintDescription* self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (new_name != NULL, NULL);
	self = (EditingToolsCropToolConstraintDescription*) g_type_create_instance (object_type);
	_tmp0_ = g_strdup (new_name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	self->basis_width = new_basis_width;
	self->basis_height = new_basis_height;
	if (new_aspect_ratio == EDITING_TOOLS_CROP_TOOL_COMPUTE_FROM_BASIS) {
		self->aspect_ratio = ((gfloat) self->basis_width) / ((gfloat) self->basis_height);
	} else {
		self->aspect_ratio = new_aspect_ratio;
	}
	self->is_pivotable = new_pivotable;
	return self;
}

static EditingToolsCropToolConstraintDescription*
editing_tools_crop_tool_constraint_description_new (const gchar* new_name,
                                                    gint new_basis_width,
                                                    gint new_basis_height,
                                                    gboolean new_pivotable,
                                                    gfloat new_aspect_ratio)
{
	return editing_tools_crop_tool_constraint_description_construct (EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION, new_name, new_basis_width, new_basis_height, new_pivotable, new_aspect_ratio);
}

static gboolean
editing_tools_crop_tool_constraint_description_is_separator (EditingToolsCropToolConstraintDescription* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_CROP_TOOL_IS_CONSTRAINT_DESCRIPTION (self), FALSE);
	if (!self->is_pivotable) {
		_tmp0_ = self->aspect_ratio == EDITING_TOOLS_CROP_TOOL_SEPARATOR;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
editing_tools_crop_tool_value_constraint_description_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
editing_tools_crop_tool_value_constraint_description_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		editing_tools_crop_tool_constraint_description_unref (value->data[0].v_pointer);
	}
}

static void
editing_tools_crop_tool_value_constraint_description_copy_value (const GValue* src_value,
                                                                 GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = editing_tools_crop_tool_constraint_description_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
editing_tools_crop_tool_value_constraint_description_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
editing_tools_crop_tool_value_constraint_description_collect_value (GValue* value,
                                                                    guint n_collect_values,
                                                                    GTypeCValue* collect_values,
                                                                    guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		EditingToolsCropToolConstraintDescription * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = editing_tools_crop_tool_constraint_description_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
editing_tools_crop_tool_value_constraint_description_lcopy_value (const GValue* value,
                                                                  guint n_collect_values,
                                                                  GTypeCValue* collect_values,
                                                                  guint collect_flags)
{
	EditingToolsCropToolConstraintDescription ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = editing_tools_crop_tool_constraint_description_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
editing_tools_crop_tool_param_spec_constraint_description (const gchar* name,
                                                           const gchar* nick,
                                                           const gchar* blurb,
                                                           GType object_type,
                                                           GParamFlags flags)
{
	EditingToolsCropToolParamSpecConstraintDescription* spec;
	g_return_val_if_fail (g_type_is_a (object_type, EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
editing_tools_crop_tool_value_get_constraint_description (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION), NULL);
	return value->data[0].v_pointer;
}

static void
editing_tools_crop_tool_value_set_constraint_description (GValue* value,
                                                          gpointer v_object)
{
	EditingToolsCropToolConstraintDescription * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		editing_tools_crop_tool_constraint_description_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		editing_tools_crop_tool_constraint_description_unref (old);
	}
}

static void
editing_tools_crop_tool_value_take_constraint_description (GValue* value,
                                                           gpointer v_object)
{
	EditingToolsCropToolConstraintDescription * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		editing_tools_crop_tool_constraint_description_unref (old);
	}
}

static void
editing_tools_crop_tool_constraint_description_class_init (EditingToolsCropToolConstraintDescriptionClass * klass,
                                                           gpointer klass_data)
{
	editing_tools_crop_tool_constraint_description_parent_class = g_type_class_peek_parent (klass);
	((EditingToolsCropToolConstraintDescriptionClass *) klass)->finalize = editing_tools_crop_tool_constraint_description_finalize;
}

static void
editing_tools_crop_tool_constraint_description_instance_init (EditingToolsCropToolConstraintDescription * self,
                                                              gpointer klass)
{
	self->ref_count = 1;
}

static void
editing_tools_crop_tool_constraint_description_finalize (EditingToolsCropToolConstraintDescription * obj)
{
	EditingToolsCropToolConstraintDescription * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_CROP_TOOL_TYPE_CONSTRAINT_DESCRIPTION, EditingToolsCropToolConstraintDescription);
	g_signal_handlers_destroy (self);
	_g_free0 (self->name);
}

static GType
editing_tools_crop_tool_constraint_description_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { editing_tools_crop_tool_value_constraint_description_init, editing_tools_crop_tool_value_constraint_description_free_value, editing_tools_crop_tool_value_constraint_description_copy_value, editing_tools_crop_tool_value_constraint_description_peek_pointer, "p", editing_tools_crop_tool_value_constraint_description_collect_value, "p", editing_tools_crop_tool_value_constraint_description_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsCropToolConstraintDescriptionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_crop_tool_constraint_description_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsCropToolConstraintDescription), 0, (GInstanceInitFunc) editing_tools_crop_tool_constraint_description_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType editing_tools_crop_tool_constraint_description_type_id;
	editing_tools_crop_tool_constraint_description_type_id = g_type_register_fundamental (g_type_fundamental_next (), "EditingToolsCropToolConstraintDescription", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return editing_tools_crop_tool_constraint_description_type_id;
}

static GType
editing_tools_crop_tool_constraint_description_get_type (void)
{
	static volatile gsize editing_tools_crop_tool_constraint_description_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_crop_tool_constraint_description_type_id__once)) {
		GType editing_tools_crop_tool_constraint_description_type_id;
		editing_tools_crop_tool_constraint_description_type_id = editing_tools_crop_tool_constraint_description_get_type_once ();
		g_once_init_leave (&editing_tools_crop_tool_constraint_description_type_id__once, editing_tools_crop_tool_constraint_description_type_id);
	}
	return editing_tools_crop_tool_constraint_description_type_id__once;
}

static gpointer
editing_tools_crop_tool_constraint_description_ref (gpointer instance)
{
	EditingToolsCropToolConstraintDescription * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
editing_tools_crop_tool_constraint_description_unref (gpointer instance)
{
	EditingToolsCropToolConstraintDescription * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		EDITING_TOOLS_CROP_TOOL_CONSTRAINT_DESCRIPTION_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static gboolean
_editing_tools_crop_tool_crop_tool_window_constraint_combo_separator_func_gtk_tree_view_row_separator_func (GtkTreeModel* model,
                                                                                                            GtkTreeIter* iter,
                                                                                                            gpointer self)
{
	gboolean result;
	result = editing_tools_crop_tool_crop_tool_window_constraint_combo_separator_func (model, iter);
	return result;
}

static EditingToolsCropToolCropToolWindow*
editing_tools_crop_tool_crop_tool_window_construct (GType object_type,
                                                    GtkWindow* container)
{
	EditingToolsCropToolCropToolWindow * self = NULL;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkButton* _tmp3_;
	GtkComboBox* _tmp4_;
	GtkCellRendererText* combo_text_renderer = NULL;
	GtkCellRendererText* _tmp5_;
	GtkComboBox* _tmp6_;
	GtkComboBox* _tmp7_;
	GtkComboBox* _tmp8_;
	GtkComboBox* _tmp9_;
	GtkImage* image = NULL;
	GtkImage* _tmp10_;
	GtkButton* _tmp11_;
	GtkButton* _tmp12_;
	GtkEntry* _tmp13_;
	GtkEntry* _tmp14_;
	GtkEntry* _tmp15_;
	GtkEntry* _tmp16_;
	GtkBox* _tmp17_;
	GtkBox* _tmp18_;
	GtkBox* _tmp19_;
	GtkButton* _tmp20_;
	GtkBox* _tmp21_;
	GtkButton* _tmp22_;
	GtkBox* _tmp23_;
	GtkBox* _tmp24_;
	GtkComboBox* _tmp25_;
	GtkBox* _tmp26_;
	GtkButton* _tmp27_;
	GtkBox* _tmp28_;
	GtkBox* _tmp29_;
	GtkBox* _tmp30_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (container, gtk_window_get_type ()), NULL);
	self = (EditingToolsCropToolCropToolWindow*) editing_tools_editing_tool_window_construct (object_type, container);
	_tmp0_ = self->cancel_button;
	gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_widget_get_type (), GtkWidget), _ ("Return to current photo dimensions"));
	_tmp1_ = self->cancel_button;
	gtk_button_set_image_position (_tmp1_, GTK_POS_LEFT);
	_tmp2_ = self->ok_button;
	gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_widget_get_type (), GtkWidget), _ ("Set the crop for this photo"));
	_tmp3_ = self->ok_button;
	gtk_button_set_image_position (_tmp3_, GTK_POS_LEFT);
	_tmp4_ = (GtkComboBox*) gtk_combo_box_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->constraint_combo);
	self->constraint_combo = _tmp4_;
	_tmp5_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp5_);
	combo_text_renderer = _tmp5_;
	_tmp6_ = self->constraint_combo;
	gtk_cell_layout_pack_start (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_cell_layout_get_type (), GtkCellLayout), G_TYPE_CHECK_INSTANCE_CAST (combo_text_renderer, gtk_cell_renderer_get_type (), GtkCellRenderer), TRUE);
	_tmp7_ = self->constraint_combo;
	gtk_cell_layout_add_attribute (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_cell_layout_get_type (), GtkCellLayout), G_TYPE_CHECK_INSTANCE_CAST (combo_text_renderer, gtk_cell_renderer_get_type (), GtkCellRenderer), "text", 0);
	_tmp8_ = self->constraint_combo;
	gtk_combo_box_set_row_separator_func (_tmp8_, _editing_tools_crop_tool_crop_tool_window_constraint_combo_separator_func_gtk_tree_view_row_separator_func, NULL, NULL);
	_tmp9_ = self->constraint_combo;
	gtk_combo_box_set_active (_tmp9_, 0);
	_tmp10_ = (GtkImage*) gtk_image_new_from_icon_name ("crop-pivot-reticle-symbolic", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp10_);
	image = _tmp10_;
	_tmp11_ = self->pivot_reticle_button;
	gtk_button_set_image (_tmp11_, G_TYPE_CHECK_INSTANCE_CAST (image, gtk_widget_get_type (), GtkWidget));
	_tmp12_ = self->pivot_reticle_button;
	gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget), _ ("Pivot the crop rectangle between portrait and landscape orientations"));
	_tmp13_ = self->custom_width_entry;
	gtk_entry_set_width_chars (_tmp13_, 4);
	_tmp14_ = self->custom_width_entry;
	g_object_set (_tmp14_, "editable", TRUE, NULL);
	_tmp15_ = self->custom_height_entry;
	gtk_entry_set_width_chars (_tmp15_, 4);
	_tmp16_ = self->custom_height_entry;
	g_object_set (_tmp16_, "editable", TRUE, NULL);
	_tmp17_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, EDITING_TOOLS_CROP_TOOL_CROP_TOOL_WINDOW_CONTROL_SPACING);
	g_object_ref_sink (_tmp17_);
	_g_object_unref0 (self->response_layout);
	self->response_layout = _tmp17_;
	_tmp18_ = self->response_layout;
	gtk_box_set_homogeneous (_tmp18_, TRUE);
	_tmp19_ = self->response_layout;
	_tmp20_ = self->cancel_button;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, gtk_widget_get_type (), GtkWidget));
	_tmp21_ = self->response_layout;
	_tmp22_ = self->ok_button;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, gtk_widget_get_type (), GtkWidget));
	_tmp23_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, EDITING_TOOLS_CROP_TOOL_CROP_TOOL_WINDOW_CONTROL_SPACING);
	g_object_ref_sink (_tmp23_);
	_g_object_unref0 (self->layout);
	self->layout = _tmp23_;
	_tmp24_ = self->layout;
	_tmp25_ = self->constraint_combo;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp24_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gtk_widget_get_type (), GtkWidget));
	_tmp26_ = self->layout;
	_tmp27_ = self->pivot_reticle_button;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp26_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, gtk_widget_get_type (), GtkWidget));
	_tmp28_ = self->layout;
	_tmp29_ = self->response_layout;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, gtk_widget_get_type (), GtkWidget));
	_tmp30_ = self->layout;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (image);
	_g_object_unref0 (combo_text_renderer);
	return self;
}

static EditingToolsCropToolCropToolWindow*
editing_tools_crop_tool_crop_tool_window_new (GtkWindow* container)
{
	return editing_tools_crop_tool_crop_tool_window_construct (EDITING_TOOLS_CROP_TOOL_TYPE_CROP_TOOL_WINDOW, container);
}

static gboolean
editing_tools_crop_tool_crop_tool_window_constraint_combo_separator_func (GtkTreeModel* model,
                                                                          GtkTreeIter* iter)
{
	GValue val = {0};
	GtkTreeIter _tmp0_;
	GValue _tmp1_ = {0};
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	gboolean result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (model, gtk_tree_model_get_type ()), FALSE);
	g_return_val_if_fail (iter != NULL, FALSE);
	_tmp0_ = *iter;
	gtk_tree_model_get_value (model, &_tmp0_, 0, &_tmp1_);
	G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
	val = _tmp1_;
	_tmp2_ = g_value_dup_string (&val);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strcmp0 (_tmp3_, "-") == 0;
	_g_free0 (_tmp3_);
	result = _tmp4_;
	G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
	return result;
}

static void
editing_tools_crop_tool_crop_tool_window_class_init (EditingToolsCropToolCropToolWindowClass * klass,
                                                     gpointer klass_data)
{
	editing_tools_crop_tool_crop_tool_window_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = editing_tools_crop_tool_crop_tool_window_finalize;
}

static void
editing_tools_crop_tool_crop_tool_window_instance_init (EditingToolsCropToolCropToolWindow * self,
                                                        gpointer klass)
{
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkEntry* _tmp3_;
	GtkEntry* _tmp4_;
	GtkLabel* _tmp5_;
	_tmp0_ = (GtkButton*) gtk_button_new_with_label (RESOURCES_CROP_LABEL);
	g_object_ref_sink (_tmp0_);
	self->ok_button = _tmp0_;
	_tmp1_ = (GtkButton*) gtk_button_new_with_mnemonic (RESOURCES_CANCEL_LABEL);
	g_object_ref_sink (_tmp1_);
	self->cancel_button = _tmp1_;
	_tmp2_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp2_);
	self->pivot_reticle_button = _tmp2_;
	_tmp3_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp3_);
	self->custom_width_entry = _tmp3_;
	_tmp4_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp4_);
	self->custom_height_entry = _tmp4_;
	_tmp5_ = (GtkLabel*) gtk_label_new_with_mnemonic ("x");
	g_object_ref_sink (_tmp5_);
	self->custom_mulsign_label = _tmp5_;
	self->most_recently_edited = NULL;
	self->response_layout = NULL;
	self->layout = NULL;
	self->normal_width = -1;
	self->normal_height = -1;
}

static void
editing_tools_crop_tool_crop_tool_window_finalize (GObject * obj)
{
	EditingToolsCropToolCropToolWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_CROP_TOOL_TYPE_CROP_TOOL_WINDOW, EditingToolsCropToolCropToolWindow);
	_g_object_unref0 (self->ok_button);
	_g_object_unref0 (self->cancel_button);
	_g_object_unref0 (self->constraint_combo);
	_g_object_unref0 (self->pivot_reticle_button);
	_g_object_unref0 (self->custom_width_entry);
	_g_object_unref0 (self->custom_height_entry);
	_g_object_unref0 (self->custom_mulsign_label);
	_g_object_unref0 (self->most_recently_edited);
	_g_object_unref0 (self->response_layout);
	_g_object_unref0 (self->layout);
	G_OBJECT_CLASS (editing_tools_crop_tool_crop_tool_window_parent_class)->finalize (obj);
}

static GType
editing_tools_crop_tool_crop_tool_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsCropToolCropToolWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_crop_tool_crop_tool_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsCropToolCropToolWindow), 0, (GInstanceInitFunc) editing_tools_crop_tool_crop_tool_window_instance_init, NULL };
	GType editing_tools_crop_tool_crop_tool_window_type_id;
	editing_tools_crop_tool_crop_tool_window_type_id = g_type_register_static (EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, "EditingToolsCropToolCropToolWindow", &g_define_type_info, 0);
	return editing_tools_crop_tool_crop_tool_window_type_id;
}

static GType
editing_tools_crop_tool_crop_tool_window_get_type (void)
{
	static volatile gsize editing_tools_crop_tool_crop_tool_window_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_crop_tool_crop_tool_window_type_id__once)) {
		GType editing_tools_crop_tool_crop_tool_window_type_id;
		editing_tools_crop_tool_crop_tool_window_type_id = editing_tools_crop_tool_crop_tool_window_get_type_once ();
		g_once_init_leave (&editing_tools_crop_tool_crop_tool_window_type_id__once, editing_tools_crop_tool_crop_tool_window_type_id);
	}
	return editing_tools_crop_tool_crop_tool_window_type_id__once;
}

static void
editing_tools_crop_tool_class_init (EditingToolsCropToolClass * klass,
                                    gpointer klass_data)
{
	editing_tools_crop_tool_parent_class = g_type_class_peek_parent (klass);
	((EditingToolsEditingToolClass *) klass)->finalize = editing_tools_crop_tool_finalize;
	g_type_class_adjust_private_offset (klass, &EditingToolsCropTool_private_offset);
	((EditingToolsEditingToolClass *) klass)->activate = (void (*) (EditingToolsEditingTool*, EditingToolsPhotoCanvas*)) editing_tools_crop_tool_real_activate;
	((EditingToolsEditingToolClass *) klass)->on_keypress = (gboolean (*) (EditingToolsEditingTool*, GdkEventKey*)) editing_tools_crop_tool_real_on_keypress;
	((EditingToolsEditingToolClass *) klass)->deactivate = (void (*) (EditingToolsEditingTool*)) editing_tools_crop_tool_real_deactivate;
	((EditingToolsEditingToolClass *) klass)->get_tool_window = (EditingToolsEditingToolWindow* (*) (EditingToolsEditingTool*)) editing_tools_crop_tool_real_get_tool_window;
	((EditingToolsEditingToolClass *) klass)->get_display_pixbuf = (GdkPixbuf* (*) (EditingToolsEditingTool*, Scaling*, Photo*, Dimensions*, GError**)) editing_tools_crop_tool_real_get_display_pixbuf;
	((EditingToolsEditingToolClass *) klass)->on_left_click = (void (*) (EditingToolsEditingTool*, gint, gint)) editing_tools_crop_tool_real_on_left_click;
	((EditingToolsEditingToolClass *) klass)->on_left_released = (void (*) (EditingToolsEditingTool*, gint, gint)) editing_tools_crop_tool_real_on_left_released;
	((EditingToolsEditingToolClass *) klass)->on_motion = (void (*) (EditingToolsEditingTool*, gint, gint, GdkModifierType)) editing_tools_crop_tool_real_on_motion;
	((EditingToolsEditingToolClass *) klass)->paint = (void (*) (EditingToolsEditingTool*, cairo_t*)) editing_tools_crop_tool_real_paint;
}

static void
editing_tools_crop_tool_instance_init (EditingToolsCropTool * self,
                                       gpointer klass)
{
	gint _tmp0_ = 0;
	EditingToolsCropToolConstraintDescription** _tmp1_;
	gint _tmp2_ = 0;
	EditingToolsCropToolConstraintDescription** _tmp3_;
	EditingToolsCropToolConstraintDescription** _tmp4_;
	gint _tmp4__length1;
	GtkListStore* _tmp5_;
	self->priv = editing_tools_crop_tool_get_instance_private (self);
	self->priv->crop_tool_window = NULL;
	self->priv->current_cursor_type = GDK_LEFT_PTR;
	self->priv->in_manipulation = BOX_LOCATION_OUTSIDE;
	self->priv->wide_black_ctx = NULL;
	self->priv->wide_white_ctx = NULL;
	self->priv->thin_white_ctx = NULL;
	self->priv->text_ctx = NULL;
	self->priv->crop_surface = NULL;
	self->priv->last_grab_x = -1;
	self->priv->last_grab_y = -1;
	_tmp1_ = editing_tools_crop_tool_create_constraints (&_tmp0_);
	self->priv->constraints = _tmp1_;
	self->priv->constraints_length1 = _tmp0_;
	self->priv->_constraints_size_ = self->priv->constraints_length1;
	_tmp3_ = editing_tools_crop_tool_create_constraints (&_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp2_;
	_tmp5_ = editing_tools_crop_tool_create_constraint_list (_tmp4_, (gint) _tmp2_);
	self->priv->constraint_list = _tmp5_;
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) editing_tools_crop_tool_constraint_description_unref), NULL);
	self->priv->reticle_orientation = EDITING_TOOLS_CROP_TOOL_RETICLE_ORIENTATION_LANDSCAPE;
	self->priv->constraint_mode = EDITING_TOOLS_CROP_TOOL_CONSTRAINT_MODE_NORMAL;
	self->priv->entry_insert_in_progress = FALSE;
	self->priv->custom_aspect_ratio = 1.0f;
	self->priv->custom_width = -1;
	self->priv->custom_height = -1;
	self->priv->custom_init_width = -1;
	self->priv->custom_init_height = -1;
	self->priv->pre_aspect_ratio = EDITING_TOOLS_CROP_TOOL_ANY_ASPECT_RATIO;
}

static void
editing_tools_crop_tool_finalize (EditingToolsEditingTool * obj)
{
	EditingToolsCropTool * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_TYPE_CROP_TOOL, EditingToolsCropTool);
	_g_object_unref0 (self->priv->crop_tool_window);
	_cairo_destroy0 (self->priv->wide_black_ctx);
	_cairo_destroy0 (self->priv->wide_white_ctx);
	_cairo_destroy0 (self->priv->thin_white_ctx);
	_cairo_destroy0 (self->priv->text_ctx);
	_cairo_surface_destroy0 (self->priv->crop_surface);
	self->priv->constraints = (_vala_array_free (self->priv->constraints, self->priv->constraints_length1, (GDestroyNotify) editing_tools_crop_tool_constraint_description_unref), NULL);
	_g_object_unref0 (self->priv->constraint_list);
	EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_crop_tool_parent_class)->finalize (obj);
}

static GType
editing_tools_crop_tool_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsCropToolClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_crop_tool_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsCropTool), 0, (GInstanceInitFunc) editing_tools_crop_tool_instance_init, NULL };
	GType editing_tools_crop_tool_type_id;
	editing_tools_crop_tool_type_id = g_type_register_static (EDITING_TOOLS_TYPE_EDITING_TOOL, "EditingToolsCropTool", &g_define_type_info, 0);
	EditingToolsCropTool_private_offset = g_type_add_instance_private (editing_tools_crop_tool_type_id, sizeof (EditingToolsCropToolPrivate));
	return editing_tools_crop_tool_type_id;
}

GType
editing_tools_crop_tool_get_type (void)
{
	static volatile gsize editing_tools_crop_tool_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_crop_tool_type_id__once)) {
		GType editing_tools_crop_tool_type_id;
		editing_tools_crop_tool_type_id = editing_tools_crop_tool_get_type_once ();
		g_once_init_leave (&editing_tools_crop_tool_type_id__once, editing_tools_crop_tool_type_id);
	}
	return editing_tools_crop_tool_type_id__once;
}

static void
editing_tools_redeye_instance_init (EditingToolsRedeyeInstance *self)
{
	GdkPoint default_center = {0};
	GdkPoint _tmp0_;
	memset (self, 0, sizeof (EditingToolsRedeyeInstance));
	memset (&default_center, 0, sizeof (GdkPoint));
	_tmp0_ = default_center;
	(*self).center = _tmp0_;
	(*self).radius = EDITING_TOOLS_REDEYE_INSTANCE_DEFAULT_RADIUS;
}

void
editing_tools_redeye_instance_to_bounds_rect (EditingToolsRedeyeInstance* inst,
                                              GdkRectangle* result)
{
	GdkRectangle _result_ = {0};
	EditingToolsRedeyeInstance _tmp0_;
	GdkPoint _tmp1_;
	EditingToolsRedeyeInstance _tmp2_;
	EditingToolsRedeyeInstance _tmp3_;
	GdkPoint _tmp4_;
	EditingToolsRedeyeInstance _tmp5_;
	EditingToolsRedeyeInstance _tmp6_;
	GdkRectangle _tmp7_;
	g_return_if_fail (inst != NULL);
	memset (&_result_, 0, sizeof (GdkRectangle));
	_tmp0_ = *inst;
	_tmp1_ = _tmp0_.center;
	_tmp2_ = *inst;
	_result_.x = _tmp1_.x - _tmp2_.radius;
	_tmp3_ = *inst;
	_tmp4_ = _tmp3_.center;
	_tmp5_ = *inst;
	_result_.y = _tmp4_.y - _tmp5_.radius;
	_tmp6_ = *inst;
	_result_.width = 2 * _tmp6_.radius;
	_tmp7_ = _result_;
	_result_.height = _tmp7_.width;
	*result = _result_;
	return;
}

void
editing_tools_redeye_instance_from_bounds_rect (GdkRectangle* rect,
                                                EditingToolsRedeyeInstance* result)
{
	GdkRectangle in_rect = {0};
	GdkRectangle _tmp0_;
	EditingToolsRedeyeInstance _result_ = {0};
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	EditingToolsRedeyeInstance _tmp4_;
	GdkRectangle _tmp5_;
	EditingToolsRedeyeInstance _tmp6_;
	g_return_if_fail (rect != NULL);
	_tmp0_ = *rect;
	in_rect = _tmp0_;
	editing_tools_redeye_instance_init (&_result_);
	_tmp1_ = in_rect;
	_tmp2_ = in_rect;
	_result_.radius = (_tmp1_.width + _tmp2_.height) / 4;
	_tmp3_ = in_rect;
	_tmp4_ = _result_;
	_result_.center.x = _tmp3_.x + _tmp4_.radius;
	_tmp5_ = in_rect;
	_tmp6_ = _result_;
	_result_.center.y = _tmp5_.y + _tmp6_.radius;
	*result = _result_;
	return;
}

EditingToolsRedeyeInstance*
editing_tools_redeye_instance_dup (const EditingToolsRedeyeInstance* self)
{
	EditingToolsRedeyeInstance* dup;
	dup = g_new0 (EditingToolsRedeyeInstance, 1);
	memcpy (dup, self, sizeof (EditingToolsRedeyeInstance));
	return dup;
}

void
editing_tools_redeye_instance_free (EditingToolsRedeyeInstance* self)
{
	g_free (self);
}

static GType
editing_tools_redeye_instance_get_type_once (void)
{
	GType editing_tools_redeye_instance_type_id;
	editing_tools_redeye_instance_type_id = g_boxed_type_register_static ("EditingToolsRedeyeInstance", (GBoxedCopyFunc) editing_tools_redeye_instance_dup, (GBoxedFreeFunc) editing_tools_redeye_instance_free);
	return editing_tools_redeye_instance_type_id;
}

GType
editing_tools_redeye_instance_get_type (void)
{
	static volatile gsize editing_tools_redeye_instance_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_redeye_instance_type_id__once)) {
		GType editing_tools_redeye_instance_type_id;
		editing_tools_redeye_instance_type_id = editing_tools_redeye_instance_get_type_once ();
		g_once_init_leave (&editing_tools_redeye_instance_type_id__once, editing_tools_redeye_instance_type_id);
	}
	return editing_tools_redeye_instance_type_id__once;
}

static inline gpointer
editing_tools_redeye_tool_get_instance_private (EditingToolsRedeyeTool* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsRedeyeTool_private_offset);
}

static EditingToolsRedeyeTool*
editing_tools_redeye_tool_construct (GType object_type)
{
	EditingToolsRedeyeTool* self = NULL;
	self = (EditingToolsRedeyeTool*) editing_tools_editing_tool_construct (object_type, "RedeyeTool");
	return self;
}

static EditingToolsRedeyeTool*
editing_tools_redeye_tool_new (void)
{
	return editing_tools_redeye_tool_construct (EDITING_TOOLS_TYPE_REDEYE_TOOL);
}

EditingToolsRedeyeTool*
editing_tools_redeye_tool_factory (void)
{
	EditingToolsRedeyeTool* _tmp0_;
	EditingToolsRedeyeTool* result;
	_tmp0_ = editing_tools_redeye_tool_new ();
	result = _tmp0_;
	return result;
}

gboolean
editing_tools_redeye_tool_is_available (Photo* photo,
                                        Scaling* scaling)
{
	Dimensions dim = {0};
	Dimensions _tmp0_ = {0};
	Dimensions _tmp1_ = {0};
	gboolean _tmp2_ = FALSE;
	Dimensions _tmp3_;
	gboolean result;
	g_return_val_if_fail (IS_PHOTO (photo), FALSE);
	g_return_val_if_fail (scaling != NULL, FALSE);
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (photo, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_NONE, &_tmp0_);
	scaling_get_scaled_dimensions (scaling, &_tmp0_, &_tmp1_);
	dim = _tmp1_;
	_tmp3_ = dim;
	if (_tmp3_.width >= (EDITING_TOOLS_REDEYE_INSTANCE_MAX_RADIUS * 2)) {
		Dimensions _tmp4_;
		_tmp4_ = dim;
		_tmp2_ = _tmp4_.height >= (EDITING_TOOLS_REDEYE_INSTANCE_MAX_RADIUS * 2);
	} else {
		_tmp2_ = FALSE;
	}
	result = _tmp2_;
	return result;
}

static void
editing_tools_redeye_tool_new_interaction_instance (EditingToolsRedeyeTool* self,
                                                    EditingToolsPhotoCanvas* canvas,
                                                    EditingToolsRedeyeInstance* result)
{
	GdkRectangle photo_bounds = {0};
	GdkRectangle _tmp0_ = {0};
	GdkPoint photo_center = {0};
	GdkPoint _tmp1_ = {0};
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	GdkRectangle _tmp4_;
	GdkRectangle _tmp5_;
	EditingToolsRedeyeInstance _result_ = {0};
	GdkPoint _tmp6_;
	GdkPoint _tmp7_;
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	editing_tools_photo_canvas_get_scaled_pixbuf_position (canvas, &_tmp0_);
	photo_bounds = _tmp0_;
	_tmp1_.x = 0;
	photo_center = _tmp1_;
	_tmp2_ = photo_bounds;
	_tmp3_ = photo_bounds;
	photo_center.x = _tmp2_.x + (_tmp3_.width / 2);
	_tmp4_ = photo_bounds;
	_tmp5_ = photo_bounds;
	photo_center.y = _tmp4_.y + (_tmp5_.height / 2);
	editing_tools_redeye_instance_init (&_result_);
	_tmp6_ = photo_center;
	_result_.center.x = _tmp6_.x;
	_tmp7_ = photo_center;
	_result_.center.y = _tmp7_.y;
	_result_.radius = EDITING_TOOLS_REDEYE_INSTANCE_DEFAULT_RADIUS;
	*result = _result_;
	return;
}

static void
editing_tools_redeye_tool_prepare_ctx (EditingToolsRedeyeTool* self,
                                       cairo_t* ctx,
                                       Dimensions* dim)
{
	gdouble scale = 0.0;
	cairo_surface_t* _tmp0_;
	cairo_t* _tmp1_;
	cairo_t* _tmp2_;
	cairo_t* _tmp3_;
	cairo_surface_t* _tmp4_;
	cairo_t* _tmp5_;
	cairo_t* _tmp6_;
	cairo_t* _tmp7_;
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (dim != NULL);
	scale = application_get_scale ();
	_tmp0_ = cairo_get_target (ctx);
	_tmp1_ = cairo_create (_tmp0_);
	_cairo_destroy0 (self->priv->wider_gray_ctx);
	self->priv->wider_gray_ctx = _tmp1_;
	_tmp2_ = self->priv->wider_gray_ctx;
	set_source_color_from_string (_tmp2_, "#111");
	_tmp3_ = self->priv->wider_gray_ctx;
	cairo_set_line_width (_tmp3_, 3 * scale);
	_tmp4_ = cairo_get_target (ctx);
	_tmp5_ = cairo_create (_tmp4_);
	_cairo_destroy0 (self->priv->thin_white_ctx);
	self->priv->thin_white_ctx = _tmp5_;
	_tmp6_ = self->priv->thin_white_ctx;
	set_source_color_from_string (_tmp6_, "#FFF");
	_tmp7_ = self->priv->thin_white_ctx;
	cairo_set_line_width (_tmp7_, 1 * scale);
}

static void
editing_tools_redeye_tool_draw_redeye_instance (EditingToolsRedeyeTool* self,
                                                EditingToolsRedeyeInstance* inst)
{
	EditingToolsPhotoCanvas* _tmp0_;
	cairo_t* _tmp1_;
	EditingToolsRedeyeInstance _tmp2_;
	GdkPoint _tmp3_;
	EditingToolsRedeyeInstance _tmp4_;
	GdkPoint _tmp5_;
	EditingToolsRedeyeInstance _tmp6_;
	EditingToolsPhotoCanvas* _tmp7_;
	cairo_t* _tmp8_;
	EditingToolsRedeyeInstance _tmp9_;
	GdkPoint _tmp10_;
	EditingToolsRedeyeInstance _tmp11_;
	GdkPoint _tmp12_;
	EditingToolsRedeyeInstance _tmp13_;
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	g_return_if_fail (inst != NULL);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp1_ = self->priv->wider_gray_ctx;
	_tmp2_ = *inst;
	_tmp3_ = _tmp2_.center;
	_tmp4_ = *inst;
	_tmp5_ = _tmp4_.center;
	_tmp6_ = *inst;
	editing_tools_photo_canvas_draw_circle (_tmp0_, _tmp1_, _tmp3_.x, _tmp5_.y, _tmp6_.radius);
	_tmp7_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp8_ = self->priv->thin_white_ctx;
	_tmp9_ = *inst;
	_tmp10_ = _tmp9_.center;
	_tmp11_ = *inst;
	_tmp12_ = _tmp11_.center;
	_tmp13_ = *inst;
	editing_tools_photo_canvas_draw_circle (_tmp7_, _tmp8_, _tmp10_.x, _tmp12_.y, _tmp13_.radius);
}

static gboolean
editing_tools_redeye_tool_on_size_slider_adjust (EditingToolsRedeyeTool* self,
                                                 GtkScrollType type)
{
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp0_;
	GtkScale* _tmp1_;
	EditingToolsPhotoCanvas* _tmp2_;
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self), FALSE);
	_tmp0_ = self->priv->redeye_tool_window;
	_tmp1_ = _tmp0_->slider;
	self->priv->user_interaction_instance.radius = (gint) gtk_range_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_range_get_type (), GtkRange));
	_tmp2_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp2_);
	result = FALSE;
	return result;
}

static void
editing_tools_redeye_tool_on_apply (EditingToolsRedeyeTool* self)
{
	GdkRectangle bounds_rect_user = {0};
	EditingToolsRedeyeInstance _tmp0_;
	GdkRectangle _tmp1_ = {0};
	GdkRectangle bounds_rect_active = {0};
	EditingToolsPhotoCanvas* _tmp2_;
	GdkRectangle _tmp3_;
	GdkRectangle _tmp4_ = {0};
	GdkRectangle bounds_rect_unscaled = {0};
	EditingToolsPhotoCanvas* _tmp5_;
	GdkRectangle _tmp6_;
	GdkRectangle _tmp7_ = {0};
	GdkRectangle bounds_rect_raw = {0};
	EditingToolsPhotoCanvas* _tmp8_;
	GdkRectangle _tmp9_;
	GdkRectangle _tmp10_ = {0};
	EditingToolsRedeyeInstance instance_raw = {0};
	GdkRectangle _tmp11_;
	EditingToolsRedeyeInstance _tmp12_ = {0};
	Dimensions dimensions = {0};
	EditingToolsPhotoCanvas* _tmp13_;
	Photo* _tmp14_;
	Photo* _tmp15_;
	Dimensions _tmp16_ = {0};
	Dimensions _tmp17_;
	gdouble theta = 0.0;
	EditingToolsPhotoCanvas* _tmp18_;
	Photo* _tmp19_;
	Photo* _tmp20_;
	gdouble _tmp21_ = 0.0;
	EditingToolsRedeyeInstance _tmp22_;
	GdkPoint _tmp23_;
	Dimensions _tmp24_;
	Dimensions _tmp25_;
	GdkPoint _tmp26_ = {0};
	RedeyeCommand* command = NULL;
	EditingToolsPhotoCanvas* _tmp27_;
	Photo* _tmp28_;
	Photo* _tmp29_;
	EditingToolsRedeyeInstance _tmp30_;
	RedeyeCommand* _tmp31_;
	RedeyeCommand* _tmp32_;
	CommandManager* _tmp33_;
	CommandManager* _tmp34_;
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	_tmp0_ = self->priv->user_interaction_instance;
	editing_tools_redeye_instance_to_bounds_rect (&_tmp0_, &_tmp1_);
	bounds_rect_user = _tmp1_;
	_tmp2_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp3_ = bounds_rect_user;
	editing_tools_photo_canvas_user_to_active_rect (_tmp2_, &_tmp3_, &_tmp4_);
	bounds_rect_active = _tmp4_;
	_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp6_ = bounds_rect_active;
	editing_tools_photo_canvas_active_to_unscaled_rect (_tmp5_, &_tmp6_, &_tmp7_);
	bounds_rect_unscaled = _tmp7_;
	_tmp8_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp9_ = bounds_rect_unscaled;
	editing_tools_photo_canvas_unscaled_to_raw_rect (_tmp8_, &_tmp9_, &_tmp10_);
	bounds_rect_raw = _tmp10_;
	_tmp11_ = bounds_rect_raw;
	editing_tools_redeye_instance_from_bounds_rect (&_tmp11_, &_tmp12_);
	instance_raw = _tmp12_;
	_tmp13_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp14_ = editing_tools_photo_canvas_get_photo (_tmp13_);
	_tmp15_ = _tmp14_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_STRAIGHTEN | PHOTO_EXCEPTION_CROP, &_tmp16_);
	_tmp17_ = _tmp16_;
	_g_object_unref0 (_tmp15_);
	dimensions = _tmp17_;
	theta = 0.0;
	_tmp18_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp19_ = editing_tools_photo_canvas_get_photo (_tmp18_);
	_tmp20_ = _tmp19_;
	photo_get_straighten (_tmp20_, &_tmp21_);
	theta = _tmp21_;
	_g_object_unref0 (_tmp20_);
	_tmp22_ = instance_raw;
	_tmp23_ = _tmp22_.center;
	_tmp24_ = dimensions;
	_tmp25_ = dimensions;
	derotate_point_arb (&_tmp23_, _tmp24_.width, _tmp25_.height, theta, &_tmp26_);
	instance_raw.center = _tmp26_;
	_tmp27_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp28_ = editing_tools_photo_canvas_get_photo (_tmp27_);
	_tmp29_ = _tmp28_;
	_tmp30_ = instance_raw;
	_tmp31_ = redeye_command_new (_tmp29_, &_tmp30_, RESOURCES_RED_EYE_LABEL, RESOURCES_RED_EYE_TOOLTIP);
	_tmp32_ = _tmp31_;
	_g_object_unref0 (_tmp29_);
	command = _tmp32_;
	_tmp33_ = app_window_get_command_manager ();
	_tmp34_ = _tmp33_;
	command_manager_execute (_tmp34_, G_TYPE_CHECK_INSTANCE_CAST (command, TYPE_COMMAND, Command));
	_command_manager_unref0 (_tmp34_);
	_g_object_unref0 (command);
}

static void
editing_tools_redeye_tool_on_photos_altered (EditingToolsRedeyeTool* self,
                                             GeeMap* map)
{
	EditingToolsPhotoCanvas* _tmp0_;
	Photo* _tmp1_;
	Photo* _tmp2_;
	gboolean _tmp3_;
	EditingToolsPhotoCanvas* _tmp15_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (map, GEE_TYPE_MAP));
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp1_ = editing_tools_photo_canvas_get_photo (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = !gee_map_has_key (map, G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, TYPE_DATA_OBJECT, DataObject));
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		return;
	}
	{
		GdkPixbuf* _tmp4_ = NULL;
		EditingToolsPhotoCanvas* _tmp5_;
		Photo* _tmp6_;
		Photo* _tmp7_;
		EditingToolsPhotoCanvas* _tmp8_;
		Scaling _tmp9_ = {0};
		GdkPixbuf* _tmp10_;
		GdkPixbuf* _tmp11_;
		GdkPixbuf* _tmp12_;
		_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp6_ = editing_tools_photo_canvas_get_photo (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_get_scaling (_tmp8_, &_tmp9_);
		_tmp10_ = photo_source_get_pixbuf (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, TYPE_PHOTO_SOURCE, PhotoSource), &_tmp9_, &_inner_error0_);
		_tmp11_ = _tmp10_;
		_g_object_unref0 (_tmp7_);
		_tmp4_ = _tmp11_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp12_ = _tmp4_;
		_tmp4_ = NULL;
		_g_object_unref0 (self->priv->current_pixbuf);
		self->priv->current_pixbuf = _tmp12_;
		_g_object_unref0 (_tmp4_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp13_;
		const gchar* _tmp14_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp13_ = err;
		_tmp14_ = _tmp13_->message;
		g_warning ("EditingTools.vala:2005: %s", _tmp14_);
		g_signal_emit (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_ABORTED_SIGNAL], 0);
		_g_error_free0 (err);
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp15_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp15_);
}

static void
editing_tools_redeye_tool_on_close (EditingToolsRedeyeTool* self)
{
	GdkPixbuf* _tmp0_;
	EditingToolsPhotoCanvas* _tmp1_;
	Photo* _tmp2_;
	Photo* _tmp3_;
	Dimensions _tmp4_ = {0};
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	_tmp0_ = self->priv->current_pixbuf;
	_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp2_ = editing_tools_photo_canvas_get_photo (_tmp1_);
	_tmp3_ = _tmp2_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_NONE, &_tmp4_);
	g_signal_emit (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_APPLIED_SIGNAL], 0, NULL, _tmp0_, &_tmp4_, FALSE);
	_g_object_unref0 (_tmp3_);
}

static void
editing_tools_redeye_tool_on_canvas_resize (EditingToolsRedeyeTool* self)
{
	GdkRectangle scaled_pixbuf_position = {0};
	EditingToolsPhotoCanvas* _tmp0_;
	GdkRectangle _tmp1_ = {0};
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	gdouble scale_factor = 0.0;
	GdkRectangle _tmp4_;
	GdkRectangle _tmp5_;
	EditingToolsRedeyeInstance _tmp6_;
	GdkPoint _tmp7_;
	EditingToolsRedeyeInstance _tmp8_;
	GdkPoint _tmp9_;
	GdkRectangle _tmp10_;
	GdkRectangle _tmp11_;
	GdkRectangle _tmp12_;
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp0_, &_tmp1_);
	scaled_pixbuf_position = _tmp1_;
	_tmp2_ = self->priv->old_scaled_pixbuf_position;
	self->priv->user_interaction_instance.center.x = self->priv->user_interaction_instance.center.x - _tmp2_.x;
	_tmp3_ = self->priv->old_scaled_pixbuf_position;
	self->priv->user_interaction_instance.center.y = self->priv->user_interaction_instance.center.y - _tmp3_.y;
	_tmp4_ = scaled_pixbuf_position;
	_tmp5_ = self->priv->old_scaled_pixbuf_position;
	scale_factor = ((gdouble) _tmp4_.width) / ((gdouble) _tmp5_.width);
	_tmp6_ = self->priv->user_interaction_instance;
	_tmp7_ = _tmp6_.center;
	self->priv->user_interaction_instance.center.x = (gint) ((((gdouble) _tmp7_.x) * scale_factor) + 0.5);
	_tmp8_ = self->priv->user_interaction_instance;
	_tmp9_ = _tmp8_.center;
	self->priv->user_interaction_instance.center.y = (gint) ((((gdouble) _tmp9_.y) * scale_factor) + 0.5);
	_tmp10_ = scaled_pixbuf_position;
	self->priv->user_interaction_instance.center.x = self->priv->user_interaction_instance.center.x + _tmp10_.x;
	_tmp11_ = scaled_pixbuf_position;
	self->priv->user_interaction_instance.center.y = self->priv->user_interaction_instance.center.y + _tmp11_.y;
	_tmp12_ = scaled_pixbuf_position;
	self->priv->old_scaled_pixbuf_position = _tmp12_;
	_g_object_unref0 (self->priv->current_pixbuf);
	self->priv->current_pixbuf = NULL;
}

static void
_editing_tools_redeye_tool_on_photos_altered_data_collection_items_altered (DataCollection* _sender,
                                                                            GeeMap* items,
                                                                            gpointer self)
{
	editing_tools_redeye_tool_on_photos_altered ((EditingToolsRedeyeTool*) self, items);
}

static void
editing_tools_redeye_tool_real_activate (EditingToolsEditingTool* base,
                                         EditingToolsPhotoCanvas* canvas)
{
	EditingToolsRedeyeTool * self;
	EditingToolsRedeyeInstance _tmp0_ = {0};
	cairo_t* _tmp1_;
	cairo_t* _tmp2_;
	Dimensions _tmp3_ = {0};
	GdkRectangle _tmp4_ = {0};
	GdkPixbuf* _tmp5_;
	GtkWindow* _tmp6_;
	GtkWindow* _tmp7_;
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp8_;
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp9_;
	GtkScale* _tmp10_;
	EditingToolsRedeyeInstance _tmp11_;
	DataCollection* owner = NULL;
	Photo* _tmp12_;
	Photo* _tmp13_;
	DataCollection* _tmp14_;
	DataCollection* _tmp15_;
	DataCollection* _tmp16_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool);
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	editing_tools_redeye_tool_new_interaction_instance (self, canvas, &_tmp0_);
	self->priv->user_interaction_instance = _tmp0_;
	_tmp1_ = editing_tools_photo_canvas_get_default_ctx (canvas);
	_tmp2_ = _tmp1_;
	editing_tools_photo_canvas_get_surface_dim (canvas, &_tmp3_);
	editing_tools_redeye_tool_prepare_ctx (self, _tmp2_, &_tmp3_);
	_cairo_destroy0 (_tmp2_);
	editing_tools_redeye_tool_bind_canvas_handlers (self, canvas);
	editing_tools_photo_canvas_get_scaled_pixbuf_position (canvas, &_tmp4_);
	self->priv->old_scaled_pixbuf_position = _tmp4_;
	_tmp5_ = editing_tools_photo_canvas_get_scaled_pixbuf (canvas);
	_g_object_unref0 (self->priv->current_pixbuf);
	self->priv->current_pixbuf = _tmp5_;
	_tmp6_ = editing_tools_photo_canvas_get_container (canvas);
	_tmp7_ = _tmp6_;
	_tmp8_ = editing_tools_redeye_tool_redeye_tool_window_new (_tmp7_);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->redeye_tool_window);
	self->priv->redeye_tool_window = _tmp8_;
	_g_object_unref0 (_tmp7_);
	_tmp9_ = self->priv->redeye_tool_window;
	_tmp10_ = _tmp9_->slider;
	_tmp11_ = self->priv->user_interaction_instance;
	gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_range_get_type (), GtkRange), (gdouble) _tmp11_.radius);
	editing_tools_redeye_tool_bind_window_handlers (self);
	_tmp12_ = editing_tools_photo_canvas_get_photo (canvas);
	_tmp13_ = _tmp12_;
	_tmp14_ = data_object_get_membership (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, TYPE_DATA_OBJECT, DataObject));
	_tmp15_ = _tmp14_;
	_g_object_unref0 (_tmp13_);
	owner = _tmp15_;
	_tmp16_ = owner;
	if (_tmp16_ != NULL) {
		DataCollection* _tmp17_;
		_tmp17_ = owner;
		g_signal_connect (_tmp17_, "items-altered", (GCallback) _editing_tools_redeye_tool_on_photos_altered_data_collection_items_altered, self);
	}
	EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_redeye_tool_parent_class)->activate (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), canvas);
	_data_collection_unref0 (owner);
}

static void
editing_tools_redeye_tool_real_deactivate (EditingToolsEditingTool* base)
{
	EditingToolsRedeyeTool * self;
	EditingToolsPhotoCanvas* _tmp0_;
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp10_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	if (_tmp0_ != NULL) {
		DataCollection* owner = NULL;
		EditingToolsPhotoCanvas* _tmp1_;
		Photo* _tmp2_;
		Photo* _tmp3_;
		DataCollection* _tmp4_;
		DataCollection* _tmp5_;
		DataCollection* _tmp6_;
		EditingToolsPhotoCanvas* _tmp9_;
		_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp2_ = editing_tools_photo_canvas_get_photo (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = data_object_get_membership (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, TYPE_DATA_OBJECT, DataObject));
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		owner = _tmp5_;
		_tmp6_ = owner;
		if (_tmp6_ != NULL) {
			DataCollection* _tmp7_;
			guint _tmp8_;
			_tmp7_ = owner;
			g_signal_parse_name ("items-altered", TYPE_DATA_COLLECTION, &_tmp8_, NULL, FALSE);
			g_signal_handlers_disconnect_matched (_tmp7_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp8_, 0, NULL, (GCallback) _editing_tools_redeye_tool_on_photos_altered_data_collection_items_altered, self);
		}
		_tmp9_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_redeye_tool_unbind_canvas_handlers (self, _tmp9_);
		_data_collection_unref0 (owner);
	}
	_tmp10_ = self->priv->redeye_tool_window;
	if (_tmp10_ != NULL) {
		EditingToolsRedeyeToolRedeyeToolWindow* _tmp11_;
		EditingToolsRedeyeToolRedeyeToolWindow* _tmp12_;
		editing_tools_redeye_tool_unbind_window_handlers (self);
		_tmp11_ = self->priv->redeye_tool_window;
		gtk_widget_hide (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_widget_get_type (), GtkWidget));
		_tmp12_ = self->priv->redeye_tool_window;
		gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget));
		_g_object_unref0 (self->priv->redeye_tool_window);
		self->priv->redeye_tool_window = NULL;
	}
	EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_redeye_tool_parent_class)->deactivate (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
}

static void
_editing_tools_redeye_tool_prepare_ctx_editing_tools_photo_canvas_new_surface (EditingToolsPhotoCanvas* _sender,
                                                                               cairo_t* ctx,
                                                                               Dimensions* dim,
                                                                               gpointer self)
{
	editing_tools_redeye_tool_prepare_ctx ((EditingToolsRedeyeTool*) self, ctx, dim);
}

static void
_editing_tools_redeye_tool_on_canvas_resize_editing_tools_photo_canvas_resized_scaled_pixbuf (EditingToolsPhotoCanvas* _sender,
                                                                                              Dimensions* old_dim,
                                                                                              GdkPixbuf* scaled,
                                                                                              GdkRectangle* scaled_position,
                                                                                              gpointer self)
{
	editing_tools_redeye_tool_on_canvas_resize ((EditingToolsRedeyeTool*) self);
}

static void
editing_tools_redeye_tool_bind_canvas_handlers (EditingToolsRedeyeTool* self,
                                                EditingToolsPhotoCanvas* canvas)
{
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	g_signal_connect (canvas, "new-surface", (GCallback) _editing_tools_redeye_tool_prepare_ctx_editing_tools_photo_canvas_new_surface, self);
	g_signal_connect (canvas, "resized-scaled-pixbuf", (GCallback) _editing_tools_redeye_tool_on_canvas_resize_editing_tools_photo_canvas_resized_scaled_pixbuf, self);
}

static void
editing_tools_redeye_tool_unbind_canvas_handlers (EditingToolsRedeyeTool* self,
                                                  EditingToolsPhotoCanvas* canvas)
{
	guint _tmp0_;
	guint _tmp1_;
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	g_signal_parse_name ("new-surface", EDITING_TOOLS_TYPE_PHOTO_CANVAS, &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (canvas, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _editing_tools_redeye_tool_prepare_ctx_editing_tools_photo_canvas_new_surface, self);
	g_signal_parse_name ("resized-scaled-pixbuf", EDITING_TOOLS_TYPE_PHOTO_CANVAS, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (canvas, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _editing_tools_redeye_tool_on_canvas_resize_editing_tools_photo_canvas_resized_scaled_pixbuf, self);
}

static void
_editing_tools_redeye_tool_on_apply_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self)
{
	editing_tools_redeye_tool_on_apply ((EditingToolsRedeyeTool*) self);
}

static void
_editing_tools_redeye_tool_on_close_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self)
{
	editing_tools_redeye_tool_on_close ((EditingToolsRedeyeTool*) self);
}

static gboolean
_editing_tools_redeye_tool_on_size_slider_adjust_gtk_range_change_value (GtkRange* _sender,
                                                                         GtkScrollType scroll,
                                                                         gdouble new_value,
                                                                         gpointer self)
{
	gboolean result;
	result = editing_tools_redeye_tool_on_size_slider_adjust ((EditingToolsRedeyeTool*) self, scroll);
	return result;
}

static void
editing_tools_redeye_tool_bind_window_handlers (EditingToolsRedeyeTool* self)
{
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp0_;
	GtkButton* _tmp1_;
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp2_;
	GtkButton* _tmp3_;
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp4_;
	GtkScale* _tmp5_;
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	_tmp0_ = self->priv->redeye_tool_window;
	_tmp1_ = _tmp0_->apply_button;
	g_signal_connect (_tmp1_, "clicked", (GCallback) _editing_tools_redeye_tool_on_apply_gtk_button_clicked, self);
	_tmp2_ = self->priv->redeye_tool_window;
	_tmp3_ = _tmp2_->close_button;
	g_signal_connect (_tmp3_, "clicked", (GCallback) _editing_tools_redeye_tool_on_close_gtk_button_clicked, self);
	_tmp4_ = self->priv->redeye_tool_window;
	_tmp5_ = _tmp4_->slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_range_get_type (), GtkRange), "change-value", (GCallback) _editing_tools_redeye_tool_on_size_slider_adjust_gtk_range_change_value, self);
}

static void
editing_tools_redeye_tool_unbind_window_handlers (EditingToolsRedeyeTool* self)
{
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp0_;
	GtkButton* _tmp1_;
	guint _tmp2_;
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp3_;
	GtkButton* _tmp4_;
	guint _tmp5_;
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp6_;
	GtkScale* _tmp7_;
	guint _tmp8_;
	g_return_if_fail (EDITING_TOOLS_IS_REDEYE_TOOL (self));
	_tmp0_ = self->priv->redeye_tool_window;
	_tmp1_ = _tmp0_->apply_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp2_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _editing_tools_redeye_tool_on_apply_gtk_button_clicked, self);
	_tmp3_ = self->priv->redeye_tool_window;
	_tmp4_ = _tmp3_->close_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp5_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _editing_tools_redeye_tool_on_close_gtk_button_clicked, self);
	_tmp6_ = self->priv->redeye_tool_window;
	_tmp7_ = _tmp6_->slider;
	g_signal_parse_name ("change-value", gtk_range_get_type (), &_tmp8_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_range_get_type (), GtkRange), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp8_, 0, NULL, (GCallback) _editing_tools_redeye_tool_on_size_slider_adjust_gtk_range_change_value, self);
}

static EditingToolsEditingToolWindow*
editing_tools_redeye_tool_real_get_tool_window (EditingToolsEditingTool* base)
{
	EditingToolsRedeyeTool * self;
	EditingToolsRedeyeToolRedeyeToolWindow* _tmp0_;
	EditingToolsEditingToolWindow* _tmp1_;
	EditingToolsEditingToolWindow* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool);
	_tmp0_ = self->priv->redeye_tool_window;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow));
	result = _tmp1_;
	return result;
}

static void
editing_tools_redeye_tool_real_paint (EditingToolsEditingTool* base,
                                      cairo_t* ctx)
{
	EditingToolsRedeyeTool * self;
	GdkPixbuf* _tmp0_ = NULL;
	GdkPixbuf* _tmp1_;
	EditingToolsPhotoCanvas* _tmp6_;
	EditingToolsRedeyeInstance active_inst = {0};
	EditingToolsRedeyeInstance _tmp7_;
	EditingToolsPhotoCanvas* _tmp8_;
	EditingToolsRedeyeInstance _tmp9_;
	GdkPoint _tmp10_;
	GdkPoint _tmp11_ = {0};
	EditingToolsRedeyeInstance _tmp12_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool);
	g_return_if_fail (ctx != NULL);
	_tmp1_ = self->priv->current_pixbuf;
	if (_tmp1_ != NULL) {
		GdkPixbuf* _tmp2_;
		GdkPixbuf* _tmp3_;
		_tmp2_ = self->priv->current_pixbuf;
		_tmp3_ = _g_object_ref0 (_tmp2_);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = _tmp3_;
	} else {
		EditingToolsPhotoCanvas* _tmp4_;
		GdkPixbuf* _tmp5_;
		_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp5_ = editing_tools_photo_canvas_get_scaled_pixbuf (_tmp4_);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = _tmp5_;
	}
	_tmp6_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_paint_pixbuf (_tmp6_, _tmp0_);
	_tmp7_ = self->priv->user_interaction_instance;
	active_inst = _tmp7_;
	_tmp8_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp9_ = self->priv->user_interaction_instance;
	_tmp10_ = _tmp9_.center;
	editing_tools_photo_canvas_user_to_active_point (_tmp8_, &_tmp10_, &_tmp11_);
	active_inst.center = _tmp11_;
	_tmp12_ = active_inst;
	editing_tools_redeye_tool_draw_redeye_instance (self, &_tmp12_);
	_g_object_unref0 (_tmp0_);
}

static void
editing_tools_redeye_tool_real_on_left_click (EditingToolsEditingTool* base,
                                              gint x,
                                              gint y)
{
	EditingToolsRedeyeTool * self;
	gdouble scale = 0.0;
	GdkRectangle bounds_rect = {0};
	EditingToolsRedeyeInstance _tmp0_;
	GdkRectangle _tmp1_ = {0};
	GdkRectangle _tmp2_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool);
	scale = application_get_scale ();
	_tmp0_ = self->priv->user_interaction_instance;
	editing_tools_redeye_instance_to_bounds_rect (&_tmp0_, &_tmp1_);
	bounds_rect = _tmp1_;
	_tmp2_ = bounds_rect;
	if (coord_in_rectangle ((gint) lround (x * scale), (gint) lround (y * scale), &_tmp2_)) {
		EditingToolsRedeyeInstance _tmp3_;
		GdkPoint _tmp4_;
		self->priv->is_reticle_move_in_progress = TRUE;
		self->priv->reticle_move_mouse_start_point.x = (gint) lround (x * scale);
		self->priv->reticle_move_mouse_start_point.y = (gint) lround (y * scale);
		_tmp3_ = self->priv->user_interaction_instance;
		_tmp4_ = _tmp3_.center;
		self->priv->reticle_move_anchor = _tmp4_;
	}
}

static void
editing_tools_redeye_tool_real_on_left_released (EditingToolsEditingTool* base,
                                                 gint x,
                                                 gint y)
{
	EditingToolsRedeyeTool * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool);
	self->priv->is_reticle_move_in_progress = FALSE;
}

static void
editing_tools_redeye_tool_real_on_motion (EditingToolsEditingTool* base,
                                          gint x,
                                          gint y,
                                          GdkModifierType mask)
{
	EditingToolsRedeyeTool * self;
	gdouble scale = 0.0;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool);
	scale = application_get_scale ();
	if (self->priv->is_reticle_move_in_progress) {
		GdkRectangle active_region_rect = {0};
		EditingToolsPhotoCanvas* _tmp0_;
		GdkRectangle _tmp1_ = {0};
		gint x_clamp_low = 0;
		GdkRectangle _tmp2_;
		EditingToolsRedeyeInstance _tmp3_;
		gint y_clamp_low = 0;
		GdkRectangle _tmp4_;
		EditingToolsRedeyeInstance _tmp5_;
		gint x_clamp_high = 0;
		GdkRectangle _tmp6_;
		GdkRectangle _tmp7_;
		EditingToolsRedeyeInstance _tmp8_;
		gint y_clamp_high = 0;
		GdkRectangle _tmp9_;
		GdkRectangle _tmp10_;
		EditingToolsRedeyeInstance _tmp11_;
		gint delta_x = 0;
		GdkPoint _tmp12_;
		gint delta_y = 0;
		GdkPoint _tmp13_;
		GdkPoint _tmp14_;
		GdkPoint _tmp15_;
		GdkPoint _tmp16_;
		GdkPoint _tmp17_;
		EditingToolsPhotoCanvas* _tmp18_;
		_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_get_scaled_pixbuf_position (_tmp0_, &_tmp1_);
		active_region_rect = _tmp1_;
		_tmp2_ = active_region_rect;
		_tmp3_ = self->priv->user_interaction_instance;
		x_clamp_low = (_tmp2_.x + _tmp3_.radius) + 1;
		_tmp4_ = active_region_rect;
		_tmp5_ = self->priv->user_interaction_instance;
		y_clamp_low = (_tmp4_.y + _tmp5_.radius) + 1;
		_tmp6_ = active_region_rect;
		_tmp7_ = active_region_rect;
		_tmp8_ = self->priv->user_interaction_instance;
		x_clamp_high = ((_tmp6_.x + _tmp7_.width) - _tmp8_.radius) - 1;
		_tmp9_ = active_region_rect;
		_tmp10_ = active_region_rect;
		_tmp11_ = self->priv->user_interaction_instance;
		y_clamp_high = ((_tmp9_.y + _tmp10_.height) - _tmp11_.radius) - 1;
		_tmp12_ = self->priv->reticle_move_mouse_start_point;
		delta_x = ((gint) lround (x * scale)) - _tmp12_.x;
		_tmp13_ = self->priv->reticle_move_mouse_start_point;
		delta_y = ((gint) lround (y * scale)) - _tmp13_.y;
		_tmp14_ = self->priv->reticle_move_anchor;
		self->priv->user_interaction_instance.center.x = _tmp14_.x + delta_x;
		_tmp15_ = self->priv->reticle_move_anchor;
		self->priv->user_interaction_instance.center.y = _tmp15_.y + delta_y;
		_tmp16_ = self->priv->reticle_move_anchor;
		self->priv->user_interaction_instance.center.x = CLAMP (_tmp16_.x + delta_x, x_clamp_low, x_clamp_high);
		_tmp17_ = self->priv->reticle_move_anchor;
		self->priv->user_interaction_instance.center.y = CLAMP (_tmp17_.y + delta_y, y_clamp_low, y_clamp_high);
		_tmp18_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_photo_canvas_repaint (_tmp18_);
	} else {
		GdkRectangle bounds = {0};
		EditingToolsRedeyeInstance _tmp19_;
		GdkRectangle _tmp20_ = {0};
		GdkRectangle _tmp21_;
		_tmp19_ = self->priv->user_interaction_instance;
		editing_tools_redeye_instance_to_bounds_rect (&_tmp19_, &_tmp20_);
		bounds = _tmp20_;
		_tmp21_ = bounds;
		if (coord_in_rectangle ((gint) lround (x * scale), (gint) lround (y * scale), &_tmp21_)) {
			EditingToolsPhotoCanvas* _tmp22_;
			_tmp22_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
			editing_tools_photo_canvas_set_cursor (_tmp22_, GDK_FLEUR);
		} else {
			EditingToolsPhotoCanvas* _tmp23_;
			_tmp23_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
			editing_tools_photo_canvas_set_cursor (_tmp23_, GDK_LEFT_PTR);
		}
	}
}

static gboolean
editing_tools_redeye_tool_real_on_keypress (EditingToolsEditingTool* base,
                                            GdkEventKey* event)
{
	EditingToolsRedeyeTool * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp2_ = gdk_keyval_name (event->keyval);
	if (g_strcmp0 (_tmp2_, "KP_Enter") == 0) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp3_;
		_tmp3_ = gdk_keyval_name (event->keyval);
		_tmp1_ = g_strcmp0 (_tmp3_, "Enter") == 0;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp4_;
		_tmp4_ = gdk_keyval_name (event->keyval);
		_tmp0_ = g_strcmp0 (_tmp4_, "Return") == 0;
	}
	if (_tmp0_) {
		editing_tools_redeye_tool_on_close (self);
		result = TRUE;
		return result;
	}
	result = EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_redeye_tool_parent_class)->on_keypress (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), event);
	return result;
}

static inline gpointer
editing_tools_redeye_tool_redeye_tool_window_get_instance_private (EditingToolsRedeyeToolRedeyeToolWindow* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsRedeyeToolRedeyeToolWindow_private_offset);
}

static EditingToolsRedeyeToolRedeyeToolWindow*
editing_tools_redeye_tool_redeye_tool_window_construct (GType object_type,
                                                        GtkWindow* container)
{
	EditingToolsRedeyeToolRedeyeToolWindow * self = NULL;
	GtkScale* _tmp0_;
	GtkScale* _tmp1_;
	GtkButton* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	GtkBox* layout = NULL;
	GtkBox* _tmp6_;
	GtkLabel* _tmp7_;
	GtkScale* _tmp8_;
	GtkButton* _tmp9_;
	GtkButton* _tmp10_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (container, gtk_window_get_type ()), NULL);
	self = (EditingToolsRedeyeToolRedeyeToolWindow*) editing_tools_editing_tool_window_construct (object_type, container);
	_tmp0_ = self->slider;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_widget_get_type (), GtkWidget), 80, -1);
	_tmp1_ = self->slider;
	gtk_scale_set_draw_value (_tmp1_, FALSE);
	_tmp2_ = self->close_button;
	gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_widget_get_type (), GtkWidget), _ ("Close the red-eye tool"));
	_tmp3_ = self->close_button;
	gtk_button_set_image_position (_tmp3_, GTK_POS_LEFT);
	_tmp4_ = self->apply_button;
	gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_widget_get_type (), GtkWidget), _ ("Remove any red-eye effects in the selected region"));
	_tmp5_ = self->apply_button;
	gtk_button_set_image_position (_tmp5_, GTK_POS_LEFT);
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, EDITING_TOOLS_REDEYE_TOOL_REDEYE_TOOL_WINDOW_CONTROL_SPACING);
	g_object_ref_sink (_tmp6_);
	layout = _tmp6_;
	_tmp7_ = self->priv->slider_label;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (layout, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget));
	_tmp8_ = self->slider;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (layout, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_widget_get_type (), GtkWidget));
	_tmp9_ = self->close_button;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (layout, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_widget_get_type (), GtkWidget));
	_tmp10_ = self->apply_button;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (layout, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_widget_get_type (), GtkWidget));
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (layout, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (layout);
	return self;
}

static EditingToolsRedeyeToolRedeyeToolWindow*
editing_tools_redeye_tool_redeye_tool_window_new (GtkWindow* container)
{
	return editing_tools_redeye_tool_redeye_tool_window_construct (EDITING_TOOLS_REDEYE_TOOL_TYPE_REDEYE_TOOL_WINDOW, container);
}

static void
editing_tools_redeye_tool_redeye_tool_window_class_init (EditingToolsRedeyeToolRedeyeToolWindowClass * klass,
                                                         gpointer klass_data)
{
	editing_tools_redeye_tool_redeye_tool_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &EditingToolsRedeyeToolRedeyeToolWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = editing_tools_redeye_tool_redeye_tool_window_finalize;
}

static void
editing_tools_redeye_tool_redeye_tool_window_instance_init (EditingToolsRedeyeToolRedeyeToolWindow * self,
                                                            gpointer klass)
{
	GtkLabel* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkScale* _tmp3_;
	self->priv = editing_tools_redeye_tool_redeye_tool_window_get_instance_private (self);
	_tmp0_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Size:"));
	g_object_ref_sink (_tmp0_);
	self->priv->slider_label = _tmp0_;
	_tmp1_ = (GtkButton*) gtk_button_new_with_mnemonic (RESOURCES_APPLY_LABEL);
	g_object_ref_sink (_tmp1_);
	self->apply_button = _tmp1_;
	_tmp2_ = (GtkButton*) gtk_button_new_with_mnemonic (RESOURCES_CANCEL_LABEL);
	g_object_ref_sink (_tmp2_);
	self->close_button = _tmp2_;
	_tmp3_ = (GtkScale*) gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, (gdouble) EDITING_TOOLS_REDEYE_INSTANCE_MIN_RADIUS, (gdouble) EDITING_TOOLS_REDEYE_INSTANCE_MAX_RADIUS, 1.0);
	g_object_ref_sink (_tmp3_);
	self->slider = _tmp3_;
}

static void
editing_tools_redeye_tool_redeye_tool_window_finalize (GObject * obj)
{
	EditingToolsRedeyeToolRedeyeToolWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_REDEYE_TOOL_TYPE_REDEYE_TOOL_WINDOW, EditingToolsRedeyeToolRedeyeToolWindow);
	_g_object_unref0 (self->priv->slider_label);
	_g_object_unref0 (self->apply_button);
	_g_object_unref0 (self->close_button);
	_g_object_unref0 (self->slider);
	G_OBJECT_CLASS (editing_tools_redeye_tool_redeye_tool_window_parent_class)->finalize (obj);
}

static GType
editing_tools_redeye_tool_redeye_tool_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsRedeyeToolRedeyeToolWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_redeye_tool_redeye_tool_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsRedeyeToolRedeyeToolWindow), 0, (GInstanceInitFunc) editing_tools_redeye_tool_redeye_tool_window_instance_init, NULL };
	GType editing_tools_redeye_tool_redeye_tool_window_type_id;
	editing_tools_redeye_tool_redeye_tool_window_type_id = g_type_register_static (EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, "EditingToolsRedeyeToolRedeyeToolWindow", &g_define_type_info, 0);
	EditingToolsRedeyeToolRedeyeToolWindow_private_offset = g_type_add_instance_private (editing_tools_redeye_tool_redeye_tool_window_type_id, sizeof (EditingToolsRedeyeToolRedeyeToolWindowPrivate));
	return editing_tools_redeye_tool_redeye_tool_window_type_id;
}

static GType
editing_tools_redeye_tool_redeye_tool_window_get_type (void)
{
	static volatile gsize editing_tools_redeye_tool_redeye_tool_window_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_redeye_tool_redeye_tool_window_type_id__once)) {
		GType editing_tools_redeye_tool_redeye_tool_window_type_id;
		editing_tools_redeye_tool_redeye_tool_window_type_id = editing_tools_redeye_tool_redeye_tool_window_get_type_once ();
		g_once_init_leave (&editing_tools_redeye_tool_redeye_tool_window_type_id__once, editing_tools_redeye_tool_redeye_tool_window_type_id);
	}
	return editing_tools_redeye_tool_redeye_tool_window_type_id__once;
}

static void
editing_tools_redeye_tool_class_init (EditingToolsRedeyeToolClass * klass,
                                      gpointer klass_data)
{
	editing_tools_redeye_tool_parent_class = g_type_class_peek_parent (klass);
	((EditingToolsEditingToolClass *) klass)->finalize = editing_tools_redeye_tool_finalize;
	g_type_class_adjust_private_offset (klass, &EditingToolsRedeyeTool_private_offset);
	((EditingToolsEditingToolClass *) klass)->activate = (void (*) (EditingToolsEditingTool*, EditingToolsPhotoCanvas*)) editing_tools_redeye_tool_real_activate;
	((EditingToolsEditingToolClass *) klass)->deactivate = (void (*) (EditingToolsEditingTool*)) editing_tools_redeye_tool_real_deactivate;
	((EditingToolsEditingToolClass *) klass)->get_tool_window = (EditingToolsEditingToolWindow* (*) (EditingToolsEditingTool*)) editing_tools_redeye_tool_real_get_tool_window;
	((EditingToolsEditingToolClass *) klass)->paint = (void (*) (EditingToolsEditingTool*, cairo_t*)) editing_tools_redeye_tool_real_paint;
	((EditingToolsEditingToolClass *) klass)->on_left_click = (void (*) (EditingToolsEditingTool*, gint, gint)) editing_tools_redeye_tool_real_on_left_click;
	((EditingToolsEditingToolClass *) klass)->on_left_released = (void (*) (EditingToolsEditingTool*, gint, gint)) editing_tools_redeye_tool_real_on_left_released;
	((EditingToolsEditingToolClass *) klass)->on_motion = (void (*) (EditingToolsEditingTool*, gint, gint, GdkModifierType)) editing_tools_redeye_tool_real_on_motion;
	((EditingToolsEditingToolClass *) klass)->on_keypress = (gboolean (*) (EditingToolsEditingTool*, GdkEventKey*)) editing_tools_redeye_tool_real_on_keypress;
}

static void
editing_tools_redeye_tool_instance_init (EditingToolsRedeyeTool * self,
                                         gpointer klass)
{
	self->priv = editing_tools_redeye_tool_get_instance_private (self);
	self->priv->thin_white_ctx = NULL;
	self->priv->wider_gray_ctx = NULL;
	self->priv->redeye_tool_window = NULL;
	self->priv->is_reticle_move_in_progress = FALSE;
	self->priv->current_pixbuf = NULL;
}

static void
editing_tools_redeye_tool_finalize (EditingToolsEditingTool * obj)
{
	EditingToolsRedeyeTool * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_TYPE_REDEYE_TOOL, EditingToolsRedeyeTool);
	_cairo_destroy0 (self->priv->thin_white_ctx);
	_cairo_destroy0 (self->priv->wider_gray_ctx);
	_g_object_unref0 (self->priv->redeye_tool_window);
	_g_object_unref0 (self->priv->current_pixbuf);
	EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_redeye_tool_parent_class)->finalize (obj);
}

static GType
editing_tools_redeye_tool_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsRedeyeToolClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_redeye_tool_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsRedeyeTool), 0, (GInstanceInitFunc) editing_tools_redeye_tool_instance_init, NULL };
	GType editing_tools_redeye_tool_type_id;
	editing_tools_redeye_tool_type_id = g_type_register_static (EDITING_TOOLS_TYPE_EDITING_TOOL, "EditingToolsRedeyeTool", &g_define_type_info, 0);
	EditingToolsRedeyeTool_private_offset = g_type_add_instance_private (editing_tools_redeye_tool_type_id, sizeof (EditingToolsRedeyeToolPrivate));
	return editing_tools_redeye_tool_type_id;
}

GType
editing_tools_redeye_tool_get_type (void)
{
	static volatile gsize editing_tools_redeye_tool_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_redeye_tool_type_id__once)) {
		GType editing_tools_redeye_tool_type_id;
		editing_tools_redeye_tool_type_id = editing_tools_redeye_tool_get_type_once ();
		g_once_init_leave (&editing_tools_redeye_tool_type_id__once, editing_tools_redeye_tool_type_id);
	}
	return editing_tools_redeye_tool_type_id__once;
}

static inline gpointer
editing_tools_adjust_tool_get_instance_private (EditingToolsAdjustTool* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsAdjustTool_private_offset);
}

static EditingToolsAdjustTool*
editing_tools_adjust_tool_construct (GType object_type)
{
	EditingToolsAdjustTool* self = NULL;
	self = (EditingToolsAdjustTool*) editing_tools_editing_tool_construct (object_type, "AdjustTool");
	return self;
}

static EditingToolsAdjustTool*
editing_tools_adjust_tool_new (void)
{
	return editing_tools_adjust_tool_construct (EDITING_TOOLS_TYPE_ADJUST_TOOL);
}

EditingToolsAdjustTool*
editing_tools_adjust_tool_factory (void)
{
	EditingToolsAdjustTool* _tmp0_;
	EditingToolsAdjustTool* result;
	_tmp0_ = editing_tools_adjust_tool_new ();
	result = _tmp0_;
	return result;
}

gboolean
editing_tools_adjust_tool_is_available (Photo* photo,
                                        Scaling* scaling)
{
	gboolean result;
	g_return_val_if_fail (IS_PHOTO (photo), FALSE);
	g_return_val_if_fail (scaling != NULL, FALSE);
	result = TRUE;
	return result;
}

static void
_editing_tools_adjust_tool_on_photos_altered_data_collection_items_altered (DataCollection* _sender,
                                                                            GeeMap* items,
                                                                            gpointer self)
{
	editing_tools_adjust_tool_on_photos_altered ((EditingToolsAdjustTool*) self, items);
}

static void
editing_tools_adjust_tool_real_activate (EditingToolsEditingTool* base,
                                         EditingToolsPhotoCanvas* canvas)
{
	EditingToolsAdjustTool * self;
	GtkWindow* _tmp0_;
	GtkWindow* _tmp1_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp2_;
	Photo* photo = NULL;
	Photo* _tmp3_;
	Photo* _tmp4_;
	PixelTransformationBundle* _tmp5_;
	PixelTransformationBundle* _tmp6_;
	PixelTransformer* _tmp7_;
	PixelTransformer* _tmp8_;
	ExpansionTransformation* expansion_trans = NULL;
	PixelTransformationBundle* _tmp9_;
	PixelTransformation* _tmp10_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp11_;
	RGBHistogramManipulator* _tmp12_;
	ExpansionTransformation* _tmp13_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp14_;
	RGBHistogramManipulator* _tmp15_;
	ExpansionTransformation* _tmp16_;
	ShadowDetailTransformation* shadows_trans = NULL;
	PixelTransformationBundle* _tmp17_;
	PixelTransformation* _tmp18_;
	PixelTransformer* _tmp19_;
	ShadowDetailTransformation* _tmp20_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp21_;
	GtkScale* _tmp22_;
	ShadowDetailTransformation* _tmp23_;
	HighlightDetailTransformation* highlights_trans = NULL;
	PixelTransformationBundle* _tmp24_;
	PixelTransformation* _tmp25_;
	PixelTransformer* _tmp26_;
	HighlightDetailTransformation* _tmp27_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp28_;
	GtkScale* _tmp29_;
	HighlightDetailTransformation* _tmp30_;
	TemperatureTransformation* temp_trans = NULL;
	PixelTransformationBundle* _tmp31_;
	PixelTransformation* _tmp32_;
	PixelTransformer* _tmp33_;
	TemperatureTransformation* _tmp34_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp35_;
	GtkScale* _tmp36_;
	TemperatureTransformation* _tmp37_;
	TintTransformation* tint_trans = NULL;
	PixelTransformationBundle* _tmp38_;
	PixelTransformation* _tmp39_;
	PixelTransformer* _tmp40_;
	TintTransformation* _tmp41_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp42_;
	GtkScale* _tmp43_;
	TintTransformation* _tmp44_;
	SaturationTransformation* sat_trans = NULL;
	PixelTransformationBundle* _tmp45_;
	PixelTransformation* _tmp46_;
	PixelTransformer* _tmp47_;
	SaturationTransformation* _tmp48_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp49_;
	GtkScale* _tmp50_;
	SaturationTransformation* _tmp51_;
	ExposureTransformation* exposure_trans = NULL;
	PixelTransformationBundle* _tmp52_;
	PixelTransformation* _tmp53_;
	PixelTransformer* _tmp54_;
	ExposureTransformation* _tmp55_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp56_;
	GtkScale* _tmp57_;
	ExposureTransformation* _tmp58_;
	ContrastTransformation* contrast_trans = NULL;
	PixelTransformationBundle* _tmp59_;
	PixelTransformation* _tmp60_;
	PixelTransformer* _tmp61_;
	ContrastTransformation* _tmp62_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp63_;
	GtkScale* _tmp64_;
	ContrastTransformation* _tmp65_;
	GdkPixbuf* _tmp66_;
	GdkPixbuf* _tmp67_;
	GdkPixbuf* _tmp68_;
	GdkPixbuf* _tmp69_;
	GdkPixbuf* _tmp70_;
	gboolean _tmp71_ = FALSE;
	GdkPixbuf* _tmp72_;
	gint _tmp73_;
	gint _tmp74_;
	gboolean _tmp78_ = FALSE;
	gboolean _tmp79_ = FALSE;
	GdkPixbuf* _tmp80_;
	gint _tmp81_;
	gint _tmp82_;
	GdkPixbuf* _tmp83_;
	gint _tmp84_;
	gint _tmp85_;
	GdkPixbuf* _tmp102_;
	GdkPixbuf* _tmp103_;
	DataCollection* owner = NULL;
	Photo* _tmp104_;
	Photo* _tmp105_;
	DataCollection* _tmp106_;
	DataCollection* _tmp107_;
	DataCollection* _tmp108_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustTool);
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	_tmp0_ = editing_tools_photo_canvas_get_container (canvas);
	_tmp1_ = _tmp0_;
	_tmp2_ = editing_tools_adjust_tool_adjust_tool_window_new (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->adjust_tool_window);
	self->priv->adjust_tool_window = _tmp2_;
	_g_object_unref0 (_tmp1_);
	_tmp3_ = editing_tools_photo_canvas_get_photo (canvas);
	photo = _tmp3_;
	_tmp4_ = photo;
	_tmp5_ = photo_get_color_adjustments (_tmp4_);
	_pixel_transformation_bundle_unref0 (self->priv->transformations);
	self->priv->transformations = _tmp5_;
	_tmp6_ = self->priv->transformations;
	_tmp7_ = pixel_transformation_bundle_generate_transformer (_tmp6_);
	_pixel_transformer_unref0 (self->priv->transformer);
	self->priv->transformer = _tmp7_;
	_tmp8_ = pixel_transformer_new ();
	_pixel_transformer_unref0 (self->priv->histogram_transformer);
	self->priv->histogram_transformer = _tmp8_;
	_tmp9_ = self->priv->transformations;
	_tmp10_ = pixel_transformation_bundle_get_transformation (_tmp9_, PIXEL_TRANSFORMATION_TYPE_TONE_EXPANSION);
	expansion_trans = G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, TYPE_EXPANSION_TRANSFORMATION, ExpansionTransformation);
	_tmp11_ = self->priv->adjust_tool_window;
	_tmp12_ = _tmp11_->histogram_manipulator;
	_tmp13_ = expansion_trans;
	rgb_histogram_manipulator_set_left_nub_position (_tmp12_, expansion_transformation_get_black_point (_tmp13_));
	_tmp14_ = self->priv->adjust_tool_window;
	_tmp15_ = _tmp14_->histogram_manipulator;
	_tmp16_ = expansion_trans;
	rgb_histogram_manipulator_set_right_nub_position (_tmp15_, expansion_transformation_get_white_point (_tmp16_));
	_tmp17_ = self->priv->transformations;
	_tmp18_ = pixel_transformation_bundle_get_transformation (_tmp17_, PIXEL_TRANSFORMATION_TYPE_SHADOWS);
	shadows_trans = G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, TYPE_SHADOW_DETAIL_TRANSFORMATION, ShadowDetailTransformation);
	_tmp19_ = self->priv->histogram_transformer;
	_tmp20_ = shadows_trans;
	pixel_transformer_attach_transformation (_tmp19_, G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, TYPE_PIXEL_TRANSFORMATION, PixelTransformation));
	_tmp21_ = self->priv->adjust_tool_window;
	_tmp22_ = _tmp21_->shadows_slider;
	_tmp23_ = shadows_trans;
	gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, gtk_range_get_type (), GtkRange), (gdouble) shadow_detail_transformation_get_parameter (_tmp23_));
	_tmp24_ = self->priv->transformations;
	_tmp25_ = pixel_transformation_bundle_get_transformation (_tmp24_, PIXEL_TRANSFORMATION_TYPE_HIGHLIGHTS);
	highlights_trans = G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, TYPE_HIGHLIGHT_DETAIL_TRANSFORMATION, HighlightDetailTransformation);
	_tmp26_ = self->priv->histogram_transformer;
	_tmp27_ = highlights_trans;
	pixel_transformer_attach_transformation (_tmp26_, G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, TYPE_PIXEL_TRANSFORMATION, PixelTransformation));
	_tmp28_ = self->priv->adjust_tool_window;
	_tmp29_ = _tmp28_->highlights_slider;
	_tmp30_ = highlights_trans;
	gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, gtk_range_get_type (), GtkRange), (gdouble) highlight_detail_transformation_get_parameter (_tmp30_));
	_tmp31_ = self->priv->transformations;
	_tmp32_ = pixel_transformation_bundle_get_transformation (_tmp31_, PIXEL_TRANSFORMATION_TYPE_TEMPERATURE);
	temp_trans = G_TYPE_CHECK_INSTANCE_CAST (_tmp32_, TYPE_TEMPERATURE_TRANSFORMATION, TemperatureTransformation);
	_tmp33_ = self->priv->histogram_transformer;
	_tmp34_ = temp_trans;
	pixel_transformer_attach_transformation (_tmp33_, G_TYPE_CHECK_INSTANCE_CAST (_tmp34_, TYPE_PIXEL_TRANSFORMATION, PixelTransformation));
	_tmp35_ = self->priv->adjust_tool_window;
	_tmp36_ = _tmp35_->temperature_slider;
	_tmp37_ = temp_trans;
	gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp36_, gtk_range_get_type (), GtkRange), (gdouble) temperature_transformation_get_parameter (_tmp37_));
	_tmp38_ = self->priv->transformations;
	_tmp39_ = pixel_transformation_bundle_get_transformation (_tmp38_, PIXEL_TRANSFORMATION_TYPE_TINT);
	tint_trans = G_TYPE_CHECK_INSTANCE_CAST (_tmp39_, TYPE_TINT_TRANSFORMATION, TintTransformation);
	_tmp40_ = self->priv->histogram_transformer;
	_tmp41_ = tint_trans;
	pixel_transformer_attach_transformation (_tmp40_, G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, TYPE_PIXEL_TRANSFORMATION, PixelTransformation));
	_tmp42_ = self->priv->adjust_tool_window;
	_tmp43_ = _tmp42_->tint_slider;
	_tmp44_ = tint_trans;
	gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, gtk_range_get_type (), GtkRange), (gdouble) tint_transformation_get_parameter (_tmp44_));
	_tmp45_ = self->priv->transformations;
	_tmp46_ = pixel_transformation_bundle_get_transformation (_tmp45_, PIXEL_TRANSFORMATION_TYPE_SATURATION);
	sat_trans = G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, TYPE_SATURATION_TRANSFORMATION, SaturationTransformation);
	_tmp47_ = self->priv->histogram_transformer;
	_tmp48_ = sat_trans;
	pixel_transformer_attach_transformation (_tmp47_, G_TYPE_CHECK_INSTANCE_CAST (_tmp48_, TYPE_PIXEL_TRANSFORMATION, PixelTransformation));
	_tmp49_ = self->priv->adjust_tool_window;
	_tmp50_ = _tmp49_->saturation_slider;
	_tmp51_ = sat_trans;
	gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp50_, gtk_range_get_type (), GtkRange), (gdouble) saturation_transformation_get_parameter (_tmp51_));
	_tmp52_ = self->priv->transformations;
	_tmp53_ = pixel_transformation_bundle_get_transformation (_tmp52_, PIXEL_TRANSFORMATION_TYPE_EXPOSURE);
	exposure_trans = G_TYPE_CHECK_INSTANCE_CAST (_tmp53_, TYPE_EXPOSURE_TRANSFORMATION, ExposureTransformation);
	_tmp54_ = self->priv->histogram_transformer;
	_tmp55_ = exposure_trans;
	pixel_transformer_attach_transformation (_tmp54_, G_TYPE_CHECK_INSTANCE_CAST (_tmp55_, TYPE_PIXEL_TRANSFORMATION, PixelTransformation));
	_tmp56_ = self->priv->adjust_tool_window;
	_tmp57_ = _tmp56_->exposure_slider;
	_tmp58_ = exposure_trans;
	gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp57_, gtk_range_get_type (), GtkRange), (gdouble) exposure_transformation_get_parameter (_tmp58_));
	_tmp59_ = self->priv->transformations;
	_tmp60_ = pixel_transformation_bundle_get_transformation (_tmp59_, PIXEL_TRANSFORMATION_TYPE_CONTRAST);
	contrast_trans = G_TYPE_CHECK_INSTANCE_CAST (_tmp60_, TYPE_CONTRAST_TRANSFORMATION, ContrastTransformation);
	_tmp61_ = self->priv->histogram_transformer;
	_tmp62_ = contrast_trans;
	pixel_transformer_attach_transformation (_tmp61_, G_TYPE_CHECK_INSTANCE_CAST (_tmp62_, TYPE_PIXEL_TRANSFORMATION, PixelTransformation));
	_tmp63_ = self->priv->adjust_tool_window;
	_tmp64_ = _tmp63_->contrast_slider;
	_tmp65_ = contrast_trans;
	gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp64_, gtk_range_get_type (), GtkRange), (gdouble) contrast_transformation_get_parameter (_tmp65_));
	editing_tools_adjust_tool_bind_canvas_handlers (self, canvas);
	editing_tools_adjust_tool_bind_window_handlers (self);
	_tmp66_ = editing_tools_photo_canvas_get_scaled_pixbuf (canvas);
	_tmp67_ = _tmp66_;
	_tmp68_ = gdk_pixbuf_copy (_tmp67_);
	_g_object_unref0 (self->priv->draw_to_pixbuf);
	self->priv->draw_to_pixbuf = _tmp68_;
	_g_object_unref0 (_tmp67_);
	_tmp69_ = editing_tools_photo_canvas_get_scaled_pixbuf (canvas);
	_tmp70_ = _tmp69_;
	editing_tools_adjust_tool_init_fp_pixel_cache (self, _tmp70_);
	_g_object_unref0 (_tmp70_);
	_tmp72_ = self->priv->draw_to_pixbuf;
	_tmp73_ = gdk_pixbuf_get_width (_tmp72_);
	_tmp74_ = _tmp73_;
	if (_tmp74_ == 1) {
		GdkPixbuf* _tmp75_;
		gint _tmp76_;
		gint _tmp77_;
		_tmp75_ = self->priv->draw_to_pixbuf;
		_tmp76_ = gdk_pixbuf_get_height (_tmp75_);
		_tmp77_ = _tmp76_;
		_tmp71_ = _tmp77_ == 1;
	} else {
		_tmp71_ = FALSE;
	}
	if (_tmp71_) {
		self->priv->disable_histogram_refresh = TRUE;
	}
	_tmp80_ = self->priv->draw_to_pixbuf;
	_tmp81_ = gdk_pixbuf_get_width (_tmp80_);
	_tmp82_ = _tmp81_;
	_tmp83_ = self->priv->draw_to_pixbuf;
	_tmp84_ = gdk_pixbuf_get_height (_tmp83_);
	_tmp85_ = _tmp84_;
	if ((_tmp82_ * _tmp85_) > 8192) {
		GdkPixbuf* _tmp86_;
		gint _tmp87_;
		gint _tmp88_;
		_tmp86_ = self->priv->draw_to_pixbuf;
		_tmp87_ = gdk_pixbuf_get_width (_tmp86_);
		_tmp88_ = _tmp87_;
		_tmp79_ = _tmp88_ > 1;
	} else {
		_tmp79_ = FALSE;
	}
	if (_tmp79_) {
		GdkPixbuf* _tmp89_;
		gint _tmp90_;
		gint _tmp91_;
		_tmp89_ = self->priv->draw_to_pixbuf;
		_tmp90_ = gdk_pixbuf_get_height (_tmp89_);
		_tmp91_ = _tmp90_;
		_tmp78_ = _tmp91_ > 1;
	} else {
		_tmp78_ = FALSE;
	}
	if (_tmp78_) {
		GdkPixbuf* _tmp92_;
		GdkPixbuf* _tmp93_;
		gint _tmp94_;
		gint _tmp95_;
		GdkPixbuf* _tmp96_;
		gint _tmp97_;
		gint _tmp98_;
		GdkPixbuf* _tmp99_;
		_tmp92_ = self->priv->draw_to_pixbuf;
		_tmp93_ = self->priv->draw_to_pixbuf;
		_tmp94_ = gdk_pixbuf_get_width (_tmp93_);
		_tmp95_ = _tmp94_;
		_tmp96_ = self->priv->draw_to_pixbuf;
		_tmp97_ = gdk_pixbuf_get_height (_tmp96_);
		_tmp98_ = _tmp97_;
		_tmp99_ = gdk_pixbuf_scale_simple (_tmp92_, _tmp95_ / 2, _tmp98_ / 2, GDK_INTERP_HYPER);
		_g_object_unref0 (self->priv->histogram_pixbuf);
		self->priv->histogram_pixbuf = _tmp99_;
	} else {
		GdkPixbuf* _tmp100_;
		GdkPixbuf* _tmp101_;
		_tmp100_ = self->priv->draw_to_pixbuf;
		_tmp101_ = gdk_pixbuf_copy (_tmp100_);
		_g_object_unref0 (self->priv->histogram_pixbuf);
		self->priv->histogram_pixbuf = _tmp101_;
	}
	_tmp102_ = self->priv->histogram_pixbuf;
	_tmp103_ = gdk_pixbuf_copy (_tmp102_);
	_g_object_unref0 (self->priv->virgin_histogram_pixbuf);
	self->priv->virgin_histogram_pixbuf = _tmp103_;
	_tmp104_ = editing_tools_photo_canvas_get_photo (canvas);
	_tmp105_ = _tmp104_;
	_tmp106_ = data_object_get_membership (G_TYPE_CHECK_INSTANCE_CAST (_tmp105_, TYPE_DATA_OBJECT, DataObject));
	_tmp107_ = _tmp106_;
	_g_object_unref0 (_tmp105_);
	owner = _tmp107_;
	_tmp108_ = owner;
	if (_tmp108_ != NULL) {
		DataCollection* _tmp109_;
		_tmp109_ = owner;
		g_signal_connect (_tmp109_, "items-altered", (GCallback) _editing_tools_adjust_tool_on_photos_altered_data_collection_items_altered, self);
	}
	EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_adjust_tool_parent_class)->activate (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), canvas);
	_data_collection_unref0 (owner);
	_pixel_transformation_unref0 (contrast_trans);
	_pixel_transformation_unref0 (exposure_trans);
	_pixel_transformation_unref0 (sat_trans);
	_pixel_transformation_unref0 (tint_trans);
	_pixel_transformation_unref0 (temp_trans);
	_pixel_transformation_unref0 (highlights_trans);
	_pixel_transformation_unref0 (shadows_trans);
	_pixel_transformation_unref0 (expansion_trans);
	_g_object_unref0 (photo);
}

static EditingToolsEditingToolWindow*
editing_tools_adjust_tool_real_get_tool_window (EditingToolsEditingTool* base)
{
	EditingToolsAdjustTool * self;
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	EditingToolsEditingToolWindow* _tmp1_;
	EditingToolsEditingToolWindow* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustTool);
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow));
	result = _tmp1_;
	return result;
}

static void
editing_tools_adjust_tool_real_deactivate (EditingToolsEditingTool* base)
{
	EditingToolsAdjustTool * self;
	EditingToolsPhotoCanvas* _tmp0_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp10_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustTool);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	if (_tmp0_ != NULL) {
		DataCollection* owner = NULL;
		EditingToolsPhotoCanvas* _tmp1_;
		Photo* _tmp2_;
		Photo* _tmp3_;
		DataCollection* _tmp4_;
		DataCollection* _tmp5_;
		DataCollection* _tmp6_;
		EditingToolsPhotoCanvas* _tmp9_;
		_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp2_ = editing_tools_photo_canvas_get_photo (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = data_object_get_membership (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, TYPE_DATA_OBJECT, DataObject));
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		owner = _tmp5_;
		_tmp6_ = owner;
		if (_tmp6_ != NULL) {
			DataCollection* _tmp7_;
			guint _tmp8_;
			_tmp7_ = owner;
			g_signal_parse_name ("items-altered", TYPE_DATA_COLLECTION, &_tmp8_, NULL, FALSE);
			g_signal_handlers_disconnect_matched (_tmp7_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp8_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_photos_altered_data_collection_items_altered, self);
		}
		_tmp9_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		editing_tools_adjust_tool_unbind_canvas_handlers (self, _tmp9_);
		_data_collection_unref0 (owner);
	}
	_tmp10_ = self->priv->adjust_tool_window;
	if (_tmp10_ != NULL) {
		EditingToolsAdjustToolAdjustToolWindow* _tmp11_;
		EditingToolsAdjustToolAdjustToolWindow* _tmp12_;
		editing_tools_adjust_tool_unbind_window_handlers (self);
		_tmp11_ = self->priv->adjust_tool_window;
		gtk_widget_hide (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_widget_get_type (), GtkWidget));
		_tmp12_ = self->priv->adjust_tool_window;
		gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget));
		_g_object_unref0 (self->priv->adjust_tool_window);
		self->priv->adjust_tool_window = NULL;
	}
	_g_object_unref0 (self->priv->draw_to_pixbuf);
	self->priv->draw_to_pixbuf = NULL;
	self->priv->fp_pixel_cache = (g_free (self->priv->fp_pixel_cache), NULL);
	self->priv->fp_pixel_cache = NULL;
	self->priv->fp_pixel_cache_length1 = 0;
	self->priv->_fp_pixel_cache_size_ = self->priv->fp_pixel_cache_length1;
	EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_adjust_tool_parent_class)->deactivate (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
}

static void
editing_tools_adjust_tool_real_paint (EditingToolsEditingTool* base,
                                      cairo_t* ctx)
{
	EditingToolsAdjustTool * self;
	EditingToolsPhotoCanvas* _tmp8_;
	GdkPixbuf* _tmp9_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustTool);
	g_return_if_fail (ctx != NULL);
	if (!self->priv->suppress_effect_redraw) {
		PixelTransformer* _tmp0_;
		GdkPixbuf* _tmp1_;
		PixelTransformer* _tmp2_;
		GdkPixbuf* _tmp3_;
		GdkPixbuf* _tmp4_;
		_tmp0_ = self->priv->transformer;
		_tmp1_ = self->priv->draw_to_pixbuf;
		pixel_transformer_transform_from_fp (_tmp0_, &self->priv->fp_pixel_cache, (gint*) (&self->priv->fp_pixel_cache_length1), _tmp1_);
		self->priv->_fp_pixel_cache_size_ = self->priv->fp_pixel_cache_length1;
		_tmp2_ = self->priv->histogram_transformer;
		_tmp3_ = self->priv->virgin_histogram_pixbuf;
		_tmp4_ = self->priv->histogram_pixbuf;
		pixel_transformer_transform_to_other_pixbuf (_tmp2_, _tmp3_, _tmp4_, NULL, -1);
		if (!self->priv->disable_histogram_refresh) {
			EditingToolsAdjustToolAdjustToolWindow* _tmp5_;
			RGBHistogramManipulator* _tmp6_;
			GdkPixbuf* _tmp7_;
			_tmp5_ = self->priv->adjust_tool_window;
			_tmp6_ = _tmp5_->histogram_manipulator;
			_tmp7_ = self->priv->histogram_pixbuf;
			rgb_histogram_manipulator_update_histogram (_tmp6_, _tmp7_);
		}
	}
	_tmp8_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp9_ = self->priv->draw_to_pixbuf;
	editing_tools_photo_canvas_paint_pixbuf (_tmp8_, _tmp9_);
}

static GdkPixbuf*
editing_tools_adjust_tool_real_get_display_pixbuf (EditingToolsEditingTool* base,
                                                   Scaling* scaling,
                                                   Photo* photo,
                                                   Dimensions* max_dim,
                                                   GError** error)
{
	EditingToolsAdjustTool * self;
	Dimensions _vala_max_dim = {0};
	Dimensions _tmp0_ = {0};
	GdkPixbuf* _tmp1_ = NULL;
	Scaling _tmp2_;
	GdkPixbuf* _tmp3_;
	GdkPixbuf* _tmp4_;
	GError* _inner_error0_ = NULL;
	GdkPixbuf* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustTool);
	g_return_val_if_fail (scaling != NULL, NULL);
	g_return_val_if_fail (IS_PHOTO (photo), NULL);
	if (!photo_has_color_adjustments (photo)) {
		dimensions_init (&_vala_max_dim, 0, 0);
		result = NULL;
		if (max_dim) {
			*max_dim = _vala_max_dim;
		}
		return result;
	}
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (photo, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_NONE, &_tmp0_);
	_vala_max_dim = _tmp0_;
	_tmp2_ = *scaling;
	_tmp3_ = photo_get_pixbuf_with_options (photo, &_tmp2_, PHOTO_EXCEPTION_ADJUST, BACKING_FETCH_MODE_BASELINE, &_inner_error0_);
	_tmp1_ = _tmp3_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp4_ = _tmp1_;
	_tmp1_ = NULL;
	result = _tmp4_;
	_g_object_unref0 (_tmp1_);
	if (max_dim) {
		*max_dim = _vala_max_dim;
	}
	return result;
}

static void
editing_tools_adjust_tool_on_reset (EditingToolsAdjustTool* self)
{
	EditingToolsAdjustToolAdjustResetCommand* command = NULL;
	PixelTransformationBundle* _tmp0_;
	EditingToolsAdjustToolAdjustResetCommand* _tmp1_;
	CommandManager* _tmp2_;
	CommandManager* _tmp3_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->transformations;
	_tmp1_ = editing_tools_adjust_tool_adjust_reset_command_new (self, _tmp0_);
	command = _tmp1_;
	_tmp2_ = app_window_get_command_manager ();
	_tmp3_ = _tmp2_;
	command_manager_execute (_tmp3_, G_TYPE_CHECK_INSTANCE_CAST (command, TYPE_COMMAND, Command));
	_command_manager_unref0 (_tmp3_);
	_g_object_unref0 (command);
}

static void
editing_tools_adjust_tool_on_ok (EditingToolsAdjustTool* self)
{
	EditingToolsEditingToolWindow* _tmp0_;
	EditingToolsEditingToolWindow* _tmp1_;
	EditingToolsPhotoCanvas* _tmp2_;
	Photo* _tmp3_;
	Photo* _tmp4_;
	PixelTransformationBundle* _tmp5_;
	AdjustColorsSingleCommand* _tmp6_;
	AdjustColorsSingleCommand* _tmp7_;
	GdkPixbuf* _tmp8_;
	EditingToolsPhotoCanvas* _tmp9_;
	Photo* _tmp10_;
	Photo* _tmp11_;
	Dimensions _tmp12_ = {0};
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	self->priv->suppress_effect_redraw = TRUE;
	_tmp0_ = editing_tools_editing_tool_get_tool_window (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
	_tmp1_ = _tmp0_;
	gtk_widget_hide (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (_tmp1_);
	_tmp2_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp3_ = editing_tools_photo_canvas_get_photo (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->transformations;
	_tmp6_ = adjust_colors_single_command_new (_tmp4_, _tmp5_, RESOURCES_ADJUST_LABEL, RESOURCES_ADJUST_TOOLTIP);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->priv->draw_to_pixbuf;
	_tmp9_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp10_ = editing_tools_photo_canvas_get_photo (_tmp9_);
	_tmp11_ = _tmp10_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_NONE, &_tmp12_);
	g_signal_emit (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), editing_tools_editing_tool_signals[EDITING_TOOLS_EDITING_TOOL_APPLIED_SIGNAL], 0, G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, TYPE_COMMAND, Command), _tmp8_, &_tmp12_, FALSE);
	_g_object_unref0 (_tmp11_);
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (_tmp4_);
}

static void
editing_tools_adjust_tool_update_transformations (EditingToolsAdjustTool* self,
                                                  PixelTransformationBundle* new_transformations)
{
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (new_transformations, TYPE_PIXEL_TRANSFORMATION_BUNDLE));
	{
		GeeIterator* _transformation_it = NULL;
		GeeIterable* _tmp0_;
		GeeIterable* _tmp1_;
		GeeIterator* _tmp2_;
		GeeIterator* _tmp3_;
		_tmp0_ = pixel_transformation_bundle_get_transformations (new_transformations);
		_tmp1_ = _tmp0_;
		_tmp2_ = gee_iterable_iterator (_tmp1_);
		_tmp3_ = _tmp2_;
		_g_object_unref0 (_tmp1_);
		_transformation_it = _tmp3_;
		while (TRUE) {
			GeeIterator* _tmp4_;
			PixelTransformation* transformation = NULL;
			GeeIterator* _tmp5_;
			gpointer _tmp6_;
			PixelTransformation* _tmp7_;
			_tmp4_ = _transformation_it;
			if (!gee_iterator_next (_tmp4_)) {
				break;
			}
			_tmp5_ = _transformation_it;
			_tmp6_ = gee_iterator_get (_tmp5_);
			transformation = (PixelTransformation*) _tmp6_;
			_tmp7_ = transformation;
			editing_tools_adjust_tool_update_transformation (self, _tmp7_);
			_pixel_transformation_unref0 (transformation);
		}
		_g_object_unref0 (_transformation_it);
	}
}

static void
editing_tools_adjust_tool_update_transformation (EditingToolsAdjustTool* self,
                                                 PixelTransformation* new_transformation)
{
	PixelTransformation* old_transformation = NULL;
	PixelTransformationBundle* _tmp0_;
	PixelTransformation* _tmp1_;
	PixelTransformer* _tmp2_;
	PixelTransformation* _tmp3_;
	PixelTransformationBundle* _tmp6_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (new_transformation, TYPE_PIXEL_TRANSFORMATION));
	_tmp0_ = self->priv->transformations;
	_tmp1_ = pixel_transformation_bundle_get_transformation (_tmp0_, pixel_transformation_get_transformation_type (new_transformation));
	old_transformation = _tmp1_;
	_tmp2_ = self->priv->transformer;
	_tmp3_ = old_transformation;
	pixel_transformer_replace_transformation (_tmp2_, _tmp3_, new_transformation);
	if (pixel_transformation_get_transformation_type (new_transformation) != PIXEL_TRANSFORMATION_TYPE_TONE_EXPANSION) {
		PixelTransformer* _tmp4_;
		PixelTransformation* _tmp5_;
		_tmp4_ = self->priv->histogram_transformer;
		_tmp5_ = old_transformation;
		pixel_transformer_replace_transformation (_tmp4_, _tmp5_, new_transformation);
	}
	_tmp6_ = self->priv->transformations;
	pixel_transformation_bundle_set (_tmp6_, new_transformation);
	_pixel_transformation_unref0 (old_transformation);
}

static void
editing_tools_adjust_tool_slider_updated (EditingToolsAdjustTool* self,
                                          PixelTransformation* new_transformation,
                                          const gchar* name)
{
	PixelTransformation* old_transformation = NULL;
	PixelTransformationBundle* _tmp0_;
	PixelTransformation* _tmp1_;
	EditingToolsAdjustToolSliderAdjustmentCommand* command = NULL;
	EditingToolsAdjustToolSliderAdjustmentCommand* _tmp2_;
	CommandManager* _tmp3_;
	CommandManager* _tmp4_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (new_transformation, TYPE_PIXEL_TRANSFORMATION));
	g_return_if_fail (name != NULL);
	_tmp0_ = self->priv->transformations;
	_tmp1_ = pixel_transformation_bundle_get_transformation (_tmp0_, pixel_transformation_get_transformation_type (new_transformation));
	old_transformation = _tmp1_;
	_tmp2_ = editing_tools_adjust_tool_slider_adjustment_command_new (self, old_transformation, new_transformation, name);
	command = _tmp2_;
	_tmp3_ = app_window_get_command_manager ();
	_tmp4_ = _tmp3_;
	command_manager_execute (_tmp4_, G_TYPE_CHECK_INSTANCE_CAST (command, TYPE_COMMAND, Command));
	_command_manager_unref0 (_tmp4_);
	_g_object_unref0 (command);
	_pixel_transformation_unref0 (old_transformation);
}

static void
_editing_tools_adjust_tool_on_delayed_temperature_adjustment_one_shot_callback (gpointer self)
{
	editing_tools_adjust_tool_on_delayed_temperature_adjustment ((EditingToolsAdjustTool*) self);
}

static void
editing_tools_adjust_tool_on_temperature_adjustment (EditingToolsAdjustTool* self)
{
	OneShotScheduler* _tmp0_;
	OneShotScheduler* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->temperature_scheduler;
	if (_tmp0_ == NULL) {
		OneShotScheduler* _tmp1_;
		_tmp1_ = one_shot_scheduler_new ("temperature", _editing_tools_adjust_tool_on_delayed_temperature_adjustment_one_shot_callback, self);
		_one_shot_scheduler_unref0 (self->priv->temperature_scheduler);
		self->priv->temperature_scheduler = _tmp1_;
	}
	_tmp2_ = self->priv->temperature_scheduler;
	one_shot_scheduler_after_timeout (_tmp2_, EDITING_TOOLS_ADJUST_TOOL_SLIDER_DELAY_MSEC, TRUE);
}

static void
editing_tools_adjust_tool_on_delayed_temperature_adjustment (EditingToolsAdjustTool* self)
{
	TemperatureTransformation* new_temp_trans = NULL;
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	GtkScale* _tmp1_;
	TemperatureTransformation* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->temperature_slider;
	_tmp2_ = temperature_transformation_new ((gfloat) gtk_range_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_range_get_type (), GtkRange)));
	new_temp_trans = _tmp2_;
	editing_tools_adjust_tool_slider_updated (self, G_TYPE_CHECK_INSTANCE_CAST (new_temp_trans, TYPE_PIXEL_TRANSFORMATION, PixelTransformation), _ ("Temperature"));
	_pixel_transformation_unref0 (new_temp_trans);
}

static void
_editing_tools_adjust_tool_on_delayed_tint_adjustment_one_shot_callback (gpointer self)
{
	editing_tools_adjust_tool_on_delayed_tint_adjustment ((EditingToolsAdjustTool*) self);
}

static void
editing_tools_adjust_tool_on_tint_adjustment (EditingToolsAdjustTool* self)
{
	OneShotScheduler* _tmp0_;
	OneShotScheduler* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->tint_scheduler;
	if (_tmp0_ == NULL) {
		OneShotScheduler* _tmp1_;
		_tmp1_ = one_shot_scheduler_new ("tint", _editing_tools_adjust_tool_on_delayed_tint_adjustment_one_shot_callback, self);
		_one_shot_scheduler_unref0 (self->priv->tint_scheduler);
		self->priv->tint_scheduler = _tmp1_;
	}
	_tmp2_ = self->priv->tint_scheduler;
	one_shot_scheduler_after_timeout (_tmp2_, EDITING_TOOLS_ADJUST_TOOL_SLIDER_DELAY_MSEC, TRUE);
}

static void
editing_tools_adjust_tool_on_delayed_tint_adjustment (EditingToolsAdjustTool* self)
{
	TintTransformation* new_tint_trans = NULL;
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	GtkScale* _tmp1_;
	TintTransformation* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->tint_slider;
	_tmp2_ = tint_transformation_new ((gfloat) gtk_range_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_range_get_type (), GtkRange)));
	new_tint_trans = _tmp2_;
	editing_tools_adjust_tool_slider_updated (self, G_TYPE_CHECK_INSTANCE_CAST (new_tint_trans, TYPE_PIXEL_TRANSFORMATION, PixelTransformation), _ ("Tint"));
	_pixel_transformation_unref0 (new_tint_trans);
}

static void
_editing_tools_adjust_tool_on_delayed_contrast_adjustment_one_shot_callback (gpointer self)
{
	editing_tools_adjust_tool_on_delayed_contrast_adjustment ((EditingToolsAdjustTool*) self);
}

static void
editing_tools_adjust_tool_on_contrast_adjustment (EditingToolsAdjustTool* self)
{
	OneShotScheduler* _tmp0_;
	OneShotScheduler* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->contrast_scheduler;
	if (_tmp0_ == NULL) {
		OneShotScheduler* _tmp1_;
		_tmp1_ = one_shot_scheduler_new ("contrast", _editing_tools_adjust_tool_on_delayed_contrast_adjustment_one_shot_callback, self);
		_one_shot_scheduler_unref0 (self->priv->contrast_scheduler);
		self->priv->contrast_scheduler = _tmp1_;
	}
	_tmp2_ = self->priv->contrast_scheduler;
	one_shot_scheduler_after_timeout (_tmp2_, EDITING_TOOLS_ADJUST_TOOL_SLIDER_DELAY_MSEC, TRUE);
}

static void
editing_tools_adjust_tool_on_delayed_contrast_adjustment (EditingToolsAdjustTool* self)
{
	ContrastTransformation* new_exp_trans = NULL;
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	GtkScale* _tmp1_;
	ContrastTransformation* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->contrast_slider;
	_tmp2_ = contrast_transformation_new ((gfloat) gtk_range_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_range_get_type (), GtkRange)));
	new_exp_trans = _tmp2_;
	editing_tools_adjust_tool_slider_updated (self, G_TYPE_CHECK_INSTANCE_CAST (new_exp_trans, TYPE_PIXEL_TRANSFORMATION, PixelTransformation), _ ("Contrast"));
	_pixel_transformation_unref0 (new_exp_trans);
}

static void
_editing_tools_adjust_tool_on_delayed_saturation_adjustment_one_shot_callback (gpointer self)
{
	editing_tools_adjust_tool_on_delayed_saturation_adjustment ((EditingToolsAdjustTool*) self);
}

static void
editing_tools_adjust_tool_on_saturation_adjustment (EditingToolsAdjustTool* self)
{
	OneShotScheduler* _tmp0_;
	OneShotScheduler* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->saturation_scheduler;
	if (_tmp0_ == NULL) {
		OneShotScheduler* _tmp1_;
		_tmp1_ = one_shot_scheduler_new ("saturation", _editing_tools_adjust_tool_on_delayed_saturation_adjustment_one_shot_callback, self);
		_one_shot_scheduler_unref0 (self->priv->saturation_scheduler);
		self->priv->saturation_scheduler = _tmp1_;
	}
	_tmp2_ = self->priv->saturation_scheduler;
	one_shot_scheduler_after_timeout (_tmp2_, EDITING_TOOLS_ADJUST_TOOL_SLIDER_DELAY_MSEC, TRUE);
}

static void
editing_tools_adjust_tool_on_delayed_saturation_adjustment (EditingToolsAdjustTool* self)
{
	SaturationTransformation* new_sat_trans = NULL;
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	GtkScale* _tmp1_;
	SaturationTransformation* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->saturation_slider;
	_tmp2_ = saturation_transformation_new ((gfloat) gtk_range_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_range_get_type (), GtkRange)));
	new_sat_trans = _tmp2_;
	editing_tools_adjust_tool_slider_updated (self, G_TYPE_CHECK_INSTANCE_CAST (new_sat_trans, TYPE_PIXEL_TRANSFORMATION, PixelTransformation), _ ("Saturation"));
	_pixel_transformation_unref0 (new_sat_trans);
}

static void
_editing_tools_adjust_tool_on_delayed_exposure_adjustment_one_shot_callback (gpointer self)
{
	editing_tools_adjust_tool_on_delayed_exposure_adjustment ((EditingToolsAdjustTool*) self);
}

static void
editing_tools_adjust_tool_on_exposure_adjustment (EditingToolsAdjustTool* self)
{
	OneShotScheduler* _tmp0_;
	OneShotScheduler* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->exposure_scheduler;
	if (_tmp0_ == NULL) {
		OneShotScheduler* _tmp1_;
		_tmp1_ = one_shot_scheduler_new ("exposure", _editing_tools_adjust_tool_on_delayed_exposure_adjustment_one_shot_callback, self);
		_one_shot_scheduler_unref0 (self->priv->exposure_scheduler);
		self->priv->exposure_scheduler = _tmp1_;
	}
	_tmp2_ = self->priv->exposure_scheduler;
	one_shot_scheduler_after_timeout (_tmp2_, EDITING_TOOLS_ADJUST_TOOL_SLIDER_DELAY_MSEC, TRUE);
}

static void
editing_tools_adjust_tool_on_delayed_exposure_adjustment (EditingToolsAdjustTool* self)
{
	ExposureTransformation* new_exp_trans = NULL;
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	GtkScale* _tmp1_;
	ExposureTransformation* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->exposure_slider;
	_tmp2_ = exposure_transformation_new ((gfloat) gtk_range_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_range_get_type (), GtkRange)));
	new_exp_trans = _tmp2_;
	editing_tools_adjust_tool_slider_updated (self, G_TYPE_CHECK_INSTANCE_CAST (new_exp_trans, TYPE_PIXEL_TRANSFORMATION, PixelTransformation), _ ("Exposure"));
	_pixel_transformation_unref0 (new_exp_trans);
}

static void
_editing_tools_adjust_tool_on_delayed_shadows_adjustment_one_shot_callback (gpointer self)
{
	editing_tools_adjust_tool_on_delayed_shadows_adjustment ((EditingToolsAdjustTool*) self);
}

static void
editing_tools_adjust_tool_on_shadows_adjustment (EditingToolsAdjustTool* self)
{
	OneShotScheduler* _tmp0_;
	OneShotScheduler* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->shadows_scheduler;
	if (_tmp0_ == NULL) {
		OneShotScheduler* _tmp1_;
		_tmp1_ = one_shot_scheduler_new ("shadows", _editing_tools_adjust_tool_on_delayed_shadows_adjustment_one_shot_callback, self);
		_one_shot_scheduler_unref0 (self->priv->shadows_scheduler);
		self->priv->shadows_scheduler = _tmp1_;
	}
	_tmp2_ = self->priv->shadows_scheduler;
	one_shot_scheduler_after_timeout (_tmp2_, EDITING_TOOLS_ADJUST_TOOL_SLIDER_DELAY_MSEC, TRUE);
}

static void
editing_tools_adjust_tool_on_delayed_shadows_adjustment (EditingToolsAdjustTool* self)
{
	ShadowDetailTransformation* new_shadows_trans = NULL;
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	GtkScale* _tmp1_;
	ShadowDetailTransformation* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->shadows_slider;
	_tmp2_ = shadow_detail_transformation_new ((gfloat) gtk_range_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_range_get_type (), GtkRange)));
	new_shadows_trans = _tmp2_;
	editing_tools_adjust_tool_slider_updated (self, G_TYPE_CHECK_INSTANCE_CAST (new_shadows_trans, TYPE_PIXEL_TRANSFORMATION, PixelTransformation), _ ("Shadows"));
	_pixel_transformation_unref0 (new_shadows_trans);
}

static void
_editing_tools_adjust_tool_on_delayed_highlights_adjustment_one_shot_callback (gpointer self)
{
	editing_tools_adjust_tool_on_delayed_highlights_adjustment ((EditingToolsAdjustTool*) self);
}

static void
editing_tools_adjust_tool_on_highlights_adjustment (EditingToolsAdjustTool* self)
{
	OneShotScheduler* _tmp0_;
	OneShotScheduler* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->highlights_scheduler;
	if (_tmp0_ == NULL) {
		OneShotScheduler* _tmp1_;
		_tmp1_ = one_shot_scheduler_new ("highlights", _editing_tools_adjust_tool_on_delayed_highlights_adjustment_one_shot_callback, self);
		_one_shot_scheduler_unref0 (self->priv->highlights_scheduler);
		self->priv->highlights_scheduler = _tmp1_;
	}
	_tmp2_ = self->priv->highlights_scheduler;
	one_shot_scheduler_after_timeout (_tmp2_, EDITING_TOOLS_ADJUST_TOOL_SLIDER_DELAY_MSEC, TRUE);
}

static void
editing_tools_adjust_tool_on_delayed_highlights_adjustment (EditingToolsAdjustTool* self)
{
	HighlightDetailTransformation* new_highlights_trans = NULL;
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	GtkScale* _tmp1_;
	HighlightDetailTransformation* _tmp2_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->highlights_slider;
	_tmp2_ = highlight_detail_transformation_new ((gfloat) gtk_range_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_range_get_type (), GtkRange)));
	new_highlights_trans = _tmp2_;
	editing_tools_adjust_tool_slider_updated (self, G_TYPE_CHECK_INSTANCE_CAST (new_highlights_trans, TYPE_PIXEL_TRANSFORMATION, PixelTransformation), _ ("Highlights"));
	_pixel_transformation_unref0 (new_highlights_trans);
}

static void
editing_tools_adjust_tool_on_histogram_constraint (EditingToolsAdjustTool* self)
{
	gint expansion_black_point = 0;
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	RGBHistogramManipulator* _tmp1_;
	gint expansion_white_point = 0;
	EditingToolsAdjustToolAdjustToolWindow* _tmp2_;
	RGBHistogramManipulator* _tmp3_;
	ExpansionTransformation* new_exp_trans = NULL;
	ExpansionTransformation* _tmp4_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->histogram_manipulator;
	expansion_black_point = rgb_histogram_manipulator_get_left_nub_position (_tmp1_);
	_tmp2_ = self->priv->adjust_tool_window;
	_tmp3_ = _tmp2_->histogram_manipulator;
	expansion_white_point = rgb_histogram_manipulator_get_right_nub_position (_tmp3_);
	_tmp4_ = expansion_transformation_new_from_extrema (expansion_black_point, expansion_white_point);
	new_exp_trans = _tmp4_;
	editing_tools_adjust_tool_slider_updated (self, G_TYPE_CHECK_INSTANCE_CAST (new_exp_trans, TYPE_PIXEL_TRANSFORMATION, PixelTransformation), _ ("Contrast Expansion"));
	_pixel_transformation_unref0 (new_exp_trans);
}

static void
editing_tools_adjust_tool_on_canvas_resize (EditingToolsAdjustTool* self)
{
	EditingToolsPhotoCanvas* _tmp0_;
	GdkPixbuf* _tmp1_;
	GdkPixbuf* _tmp2_;
	GdkPixbuf* _tmp3_;
	EditingToolsPhotoCanvas* _tmp4_;
	GdkPixbuf* _tmp5_;
	GdkPixbuf* _tmp6_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp1_ = editing_tools_photo_canvas_get_scaled_pixbuf (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gdk_pixbuf_copy (_tmp2_);
	_g_object_unref0 (self->priv->draw_to_pixbuf);
	self->priv->draw_to_pixbuf = _tmp3_;
	_g_object_unref0 (_tmp2_);
	_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp5_ = editing_tools_photo_canvas_get_scaled_pixbuf (_tmp4_);
	_tmp6_ = _tmp5_;
	editing_tools_adjust_tool_init_fp_pixel_cache (self, _tmp6_);
	_g_object_unref0 (_tmp6_);
}

static gboolean
editing_tools_adjust_tool_on_hscale_reset (EditingToolsAdjustTool* self,
                                           GtkWidget* widget,
                                           GdkEventButton* event)
{
	GtkScale* source = NULL;
	GtkScale* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self), FALSE);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_widget_get_type ()), FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (widget, gtk_scale_get_type (), GtkScale));
	source = _tmp0_;
	if (event->button == ((guint) 1)) {
		_tmp2_ = event->type == GDK_BUTTON_PRESS;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = has_only_key_modifier (event->state, GDK_CONTROL_MASK);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GtkScale* _tmp3_;
		_tmp3_ = source;
		gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_range_get_type (), GtkRange), (gdouble) 0);
		result = TRUE;
		_g_object_unref0 (source);
		return result;
	}
	result = FALSE;
	_g_object_unref0 (source);
	return result;
}

static void
_editing_tools_adjust_tool_on_canvas_resize_editing_tools_photo_canvas_resized_scaled_pixbuf (EditingToolsPhotoCanvas* _sender,
                                                                                              Dimensions* old_dim,
                                                                                              GdkPixbuf* scaled,
                                                                                              GdkRectangle* scaled_position,
                                                                                              gpointer self)
{
	editing_tools_adjust_tool_on_canvas_resize ((EditingToolsAdjustTool*) self);
}

static void
editing_tools_adjust_tool_bind_canvas_handlers (EditingToolsAdjustTool* self,
                                                EditingToolsPhotoCanvas* canvas)
{
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	g_signal_connect (canvas, "resized-scaled-pixbuf", (GCallback) _editing_tools_adjust_tool_on_canvas_resize_editing_tools_photo_canvas_resized_scaled_pixbuf, self);
}

static void
editing_tools_adjust_tool_unbind_canvas_handlers (EditingToolsAdjustTool* self,
                                                  EditingToolsPhotoCanvas* canvas)
{
	guint _tmp0_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	g_signal_parse_name ("resized-scaled-pixbuf", EDITING_TOOLS_TYPE_PHOTO_CANVAS, &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (canvas, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_canvas_resize_editing_tools_photo_canvas_resized_scaled_pixbuf, self);
}

static void
_editing_tools_adjust_tool_on_ok_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self)
{
	editing_tools_adjust_tool_on_ok ((EditingToolsAdjustTool*) self);
}

static void
_editing_tools_adjust_tool_on_reset_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self)
{
	editing_tools_adjust_tool_on_reset ((EditingToolsAdjustTool*) self);
}

static void
_editing_tools_adjust_tool_on_exposure_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                           gpointer self)
{
	editing_tools_adjust_tool_on_exposure_adjustment ((EditingToolsAdjustTool*) self);
}

static void
_editing_tools_adjust_tool_on_contrast_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                           gpointer self)
{
	editing_tools_adjust_tool_on_contrast_adjustment ((EditingToolsAdjustTool*) self);
}

static void
_editing_tools_adjust_tool_on_saturation_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                             gpointer self)
{
	editing_tools_adjust_tool_on_saturation_adjustment ((EditingToolsAdjustTool*) self);
}

static void
_editing_tools_adjust_tool_on_tint_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                       gpointer self)
{
	editing_tools_adjust_tool_on_tint_adjustment ((EditingToolsAdjustTool*) self);
}

static void
_editing_tools_adjust_tool_on_temperature_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                              gpointer self)
{
	editing_tools_adjust_tool_on_temperature_adjustment ((EditingToolsAdjustTool*) self);
}

static void
_editing_tools_adjust_tool_on_shadows_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                          gpointer self)
{
	editing_tools_adjust_tool_on_shadows_adjustment ((EditingToolsAdjustTool*) self);
}

static void
_editing_tools_adjust_tool_on_highlights_adjustment_gtk_range_value_changed (GtkRange* _sender,
                                                                             gpointer self)
{
	editing_tools_adjust_tool_on_highlights_adjustment ((EditingToolsAdjustTool*) self);
}

static void
_editing_tools_adjust_tool_on_histogram_constraint_rgb_histogram_manipulator_nub_position_changed (RGBHistogramManipulator* _sender,
                                                                                                   gpointer self)
{
	editing_tools_adjust_tool_on_histogram_constraint ((EditingToolsAdjustTool*) self);
}

static gboolean
_editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event (GtkWidget* _sender,
                                                                          GdkEventButton* event,
                                                                          gpointer self)
{
	gboolean result;
	result = editing_tools_adjust_tool_on_hscale_reset ((EditingToolsAdjustTool*) self, _sender, event);
	return result;
}

static void
editing_tools_adjust_tool_bind_window_handlers (EditingToolsAdjustTool* self)
{
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	GtkButton* _tmp1_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp2_;
	GtkButton* _tmp3_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp4_;
	GtkButton* _tmp5_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp6_;
	GtkScale* _tmp7_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp8_;
	GtkScale* _tmp9_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp10_;
	GtkScale* _tmp11_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp12_;
	GtkScale* _tmp13_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp14_;
	GtkScale* _tmp15_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp16_;
	GtkScale* _tmp17_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp18_;
	GtkScale* _tmp19_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp20_;
	RGBHistogramManipulator* _tmp21_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp22_;
	GtkScale* _tmp23_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp24_;
	GtkScale* _tmp25_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp26_;
	GtkScale* _tmp27_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp28_;
	GtkScale* _tmp29_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp30_;
	GtkScale* _tmp31_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp32_;
	GtkScale* _tmp33_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp34_;
	GtkScale* _tmp35_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->ok_button;
	g_signal_connect (_tmp1_, "clicked", (GCallback) _editing_tools_adjust_tool_on_ok_gtk_button_clicked, self);
	_tmp2_ = self->priv->adjust_tool_window;
	_tmp3_ = _tmp2_->reset_button;
	g_signal_connect (_tmp3_, "clicked", (GCallback) _editing_tools_adjust_tool_on_reset_gtk_button_clicked, self);
	_tmp4_ = self->priv->adjust_tool_window;
	_tmp5_ = _tmp4_->cancel_button;
	g_signal_connect (_tmp5_, "clicked", (GCallback) _editing_tools_editing_tool_notify_cancel_gtk_button_clicked, G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
	_tmp6_ = self->priv->adjust_tool_window;
	_tmp7_ = _tmp6_->exposure_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_range_get_type (), GtkRange), "value-changed", (GCallback) _editing_tools_adjust_tool_on_exposure_adjustment_gtk_range_value_changed, self);
	_tmp8_ = self->priv->adjust_tool_window;
	_tmp9_ = _tmp8_->contrast_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_range_get_type (), GtkRange), "value-changed", (GCallback) _editing_tools_adjust_tool_on_contrast_adjustment_gtk_range_value_changed, self);
	_tmp10_ = self->priv->adjust_tool_window;
	_tmp11_ = _tmp10_->saturation_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_range_get_type (), GtkRange), "value-changed", (GCallback) _editing_tools_adjust_tool_on_saturation_adjustment_gtk_range_value_changed, self);
	_tmp12_ = self->priv->adjust_tool_window;
	_tmp13_ = _tmp12_->tint_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_range_get_type (), GtkRange), "value-changed", (GCallback) _editing_tools_adjust_tool_on_tint_adjustment_gtk_range_value_changed, self);
	_tmp14_ = self->priv->adjust_tool_window;
	_tmp15_ = _tmp14_->temperature_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_range_get_type (), GtkRange), "value-changed", (GCallback) _editing_tools_adjust_tool_on_temperature_adjustment_gtk_range_value_changed, self);
	_tmp16_ = self->priv->adjust_tool_window;
	_tmp17_ = _tmp16_->shadows_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, gtk_range_get_type (), GtkRange), "value-changed", (GCallback) _editing_tools_adjust_tool_on_shadows_adjustment_gtk_range_value_changed, self);
	_tmp18_ = self->priv->adjust_tool_window;
	_tmp19_ = _tmp18_->highlights_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_range_get_type (), GtkRange), "value-changed", (GCallback) _editing_tools_adjust_tool_on_highlights_adjustment_gtk_range_value_changed, self);
	_tmp20_ = self->priv->adjust_tool_window;
	_tmp21_ = _tmp20_->histogram_manipulator;
	g_signal_connect (_tmp21_, "nub-position-changed", (GCallback) _editing_tools_adjust_tool_on_histogram_constraint_rgb_histogram_manipulator_nub_position_changed, self);
	_tmp22_ = self->priv->adjust_tool_window;
	_tmp23_ = _tmp22_->saturation_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, gtk_widget_get_type (), GtkWidget), "button-press-event", (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp24_ = self->priv->adjust_tool_window;
	_tmp25_ = _tmp24_->exposure_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gtk_widget_get_type (), GtkWidget), "button-press-event", (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp26_ = self->priv->adjust_tool_window;
	_tmp27_ = _tmp26_->contrast_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, gtk_widget_get_type (), GtkWidget), "button-press-event", (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp28_ = self->priv->adjust_tool_window;
	_tmp29_ = _tmp28_->tint_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, gtk_widget_get_type (), GtkWidget), "button-press-event", (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp30_ = self->priv->adjust_tool_window;
	_tmp31_ = _tmp30_->temperature_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, gtk_widget_get_type (), GtkWidget), "button-press-event", (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp32_ = self->priv->adjust_tool_window;
	_tmp33_ = _tmp32_->shadows_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp33_, gtk_widget_get_type (), GtkWidget), "button-press-event", (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp34_ = self->priv->adjust_tool_window;
	_tmp35_ = _tmp34_->highlights_slider;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp35_, gtk_widget_get_type (), GtkWidget), "button-press-event", (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
}

static void
editing_tools_adjust_tool_unbind_window_handlers (EditingToolsAdjustTool* self)
{
	EditingToolsAdjustToolAdjustToolWindow* _tmp0_;
	GtkButton* _tmp1_;
	guint _tmp2_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp3_;
	GtkButton* _tmp4_;
	guint _tmp5_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp6_;
	GtkButton* _tmp7_;
	guint _tmp8_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp9_;
	GtkScale* _tmp10_;
	guint _tmp11_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp12_;
	GtkScale* _tmp13_;
	guint _tmp14_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp15_;
	GtkScale* _tmp16_;
	guint _tmp17_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp18_;
	GtkScale* _tmp19_;
	guint _tmp20_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp21_;
	GtkScale* _tmp22_;
	guint _tmp23_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp24_;
	GtkScale* _tmp25_;
	guint _tmp26_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp27_;
	GtkScale* _tmp28_;
	guint _tmp29_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp30_;
	RGBHistogramManipulator* _tmp31_;
	guint _tmp32_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp33_;
	GtkScale* _tmp34_;
	guint _tmp35_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp36_;
	GtkScale* _tmp37_;
	guint _tmp38_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp39_;
	GtkScale* _tmp40_;
	guint _tmp41_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp42_;
	GtkScale* _tmp43_;
	guint _tmp44_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp45_;
	GtkScale* _tmp46_;
	guint _tmp47_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp48_;
	GtkScale* _tmp49_;
	guint _tmp50_;
	EditingToolsAdjustToolAdjustToolWindow* _tmp51_;
	GtkScale* _tmp52_;
	guint _tmp53_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	_tmp0_ = self->priv->adjust_tool_window;
	_tmp1_ = _tmp0_->ok_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp2_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_ok_gtk_button_clicked, self);
	_tmp3_ = self->priv->adjust_tool_window;
	_tmp4_ = _tmp3_->reset_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp5_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_reset_gtk_button_clicked, self);
	_tmp6_ = self->priv->adjust_tool_window;
	_tmp7_ = _tmp6_->cancel_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp8_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp7_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp8_, 0, NULL, (GCallback) _editing_tools_editing_tool_notify_cancel_gtk_button_clicked, G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
	_tmp9_ = self->priv->adjust_tool_window;
	_tmp10_ = _tmp9_->exposure_slider;
	g_signal_parse_name ("value-changed", gtk_range_get_type (), &_tmp11_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_range_get_type (), GtkRange), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp11_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_exposure_adjustment_gtk_range_value_changed, self);
	_tmp12_ = self->priv->adjust_tool_window;
	_tmp13_ = _tmp12_->contrast_slider;
	g_signal_parse_name ("value-changed", gtk_range_get_type (), &_tmp14_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_range_get_type (), GtkRange), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp14_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_contrast_adjustment_gtk_range_value_changed, self);
	_tmp15_ = self->priv->adjust_tool_window;
	_tmp16_ = _tmp15_->saturation_slider;
	g_signal_parse_name ("value-changed", gtk_range_get_type (), &_tmp17_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_range_get_type (), GtkRange), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp17_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_saturation_adjustment_gtk_range_value_changed, self);
	_tmp18_ = self->priv->adjust_tool_window;
	_tmp19_ = _tmp18_->tint_slider;
	g_signal_parse_name ("value-changed", gtk_range_get_type (), &_tmp20_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_range_get_type (), GtkRange), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp20_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_tint_adjustment_gtk_range_value_changed, self);
	_tmp21_ = self->priv->adjust_tool_window;
	_tmp22_ = _tmp21_->temperature_slider;
	g_signal_parse_name ("value-changed", gtk_range_get_type (), &_tmp23_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, gtk_range_get_type (), GtkRange), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp23_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_temperature_adjustment_gtk_range_value_changed, self);
	_tmp24_ = self->priv->adjust_tool_window;
	_tmp25_ = _tmp24_->shadows_slider;
	g_signal_parse_name ("value-changed", gtk_range_get_type (), &_tmp26_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gtk_range_get_type (), GtkRange), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp26_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_shadows_adjustment_gtk_range_value_changed, self);
	_tmp27_ = self->priv->adjust_tool_window;
	_tmp28_ = _tmp27_->highlights_slider;
	g_signal_parse_name ("value-changed", gtk_range_get_type (), &_tmp29_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, gtk_range_get_type (), GtkRange), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp29_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_highlights_adjustment_gtk_range_value_changed, self);
	_tmp30_ = self->priv->adjust_tool_window;
	_tmp31_ = _tmp30_->histogram_manipulator;
	g_signal_parse_name ("nub-position-changed", TYPE_RGB_HISTOGRAM_MANIPULATOR, &_tmp32_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp31_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp32_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_histogram_constraint_rgb_histogram_manipulator_nub_position_changed, self);
	_tmp33_ = self->priv->adjust_tool_window;
	_tmp34_ = _tmp33_->saturation_slider;
	g_signal_parse_name ("button-press-event", gtk_widget_get_type (), &_tmp35_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp34_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp35_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp36_ = self->priv->adjust_tool_window;
	_tmp37_ = _tmp36_->exposure_slider;
	g_signal_parse_name ("button-press-event", gtk_widget_get_type (), &_tmp38_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp37_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp38_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp39_ = self->priv->adjust_tool_window;
	_tmp40_ = _tmp39_->contrast_slider;
	g_signal_parse_name ("button-press-event", gtk_widget_get_type (), &_tmp41_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp40_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp41_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp42_ = self->priv->adjust_tool_window;
	_tmp43_ = _tmp42_->tint_slider;
	g_signal_parse_name ("button-press-event", gtk_widget_get_type (), &_tmp44_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp44_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp45_ = self->priv->adjust_tool_window;
	_tmp46_ = _tmp45_->temperature_slider;
	g_signal_parse_name ("button-press-event", gtk_widget_get_type (), &_tmp47_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp47_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp48_ = self->priv->adjust_tool_window;
	_tmp49_ = _tmp48_->shadows_slider;
	g_signal_parse_name ("button-press-event", gtk_widget_get_type (), &_tmp50_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp49_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp50_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
	_tmp51_ = self->priv->adjust_tool_window;
	_tmp52_ = _tmp51_->highlights_slider;
	g_signal_parse_name ("button-press-event", gtk_widget_get_type (), &_tmp53_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp52_, gtk_widget_get_type (), GtkWidget), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp53_, 0, NULL, (GCallback) _editing_tools_adjust_tool_on_hscale_reset_gtk_widget_button_press_event, self);
}

gboolean
editing_tools_adjust_tool_enhance (EditingToolsAdjustTool* self)
{
	EditingToolsAdjustToolAdjustEnhanceCommand* command = NULL;
	EditingToolsPhotoCanvas* _tmp0_;
	Photo* _tmp1_;
	Photo* _tmp2_;
	EditingToolsAdjustToolAdjustEnhanceCommand* _tmp3_;
	EditingToolsAdjustToolAdjustEnhanceCommand* _tmp4_;
	CommandManager* _tmp5_;
	CommandManager* _tmp6_;
	gboolean result;
	g_return_val_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self), FALSE);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp1_ = editing_tools_photo_canvas_get_photo (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = editing_tools_adjust_tool_adjust_enhance_command_new (self, _tmp2_);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp2_);
	command = _tmp4_;
	_tmp5_ = app_window_get_command_manager ();
	_tmp6_ = _tmp5_;
	command_manager_execute (_tmp6_, G_TYPE_CHECK_INSTANCE_CAST (command, TYPE_COMMAND, Command));
	_command_manager_unref0 (_tmp6_);
	result = TRUE;
	_g_object_unref0 (command);
	return result;
}

static void
editing_tools_adjust_tool_on_photos_altered (EditingToolsAdjustTool* self,
                                             GeeMap* map)
{
	EditingToolsPhotoCanvas* _tmp0_;
	Photo* _tmp1_;
	Photo* _tmp2_;
	gboolean _tmp3_;
	PixelTransformationBundle* adjustments = NULL;
	EditingToolsPhotoCanvas* _tmp4_;
	Photo* _tmp5_;
	Photo* _tmp6_;
	PixelTransformationBundle* _tmp7_;
	PixelTransformationBundle* _tmp8_;
	PixelTransformationBundle* _tmp9_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (map, GEE_TYPE_MAP));
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp1_ = editing_tools_photo_canvas_get_photo (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = !gee_map_has_key (map, G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, TYPE_DATA_OBJECT, DataObject));
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		return;
	}
	_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp5_ = editing_tools_photo_canvas_get_photo (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = photo_get_color_adjustments (_tmp6_);
	_tmp8_ = _tmp7_;
	_g_object_unref0 (_tmp6_);
	adjustments = _tmp8_;
	_tmp9_ = adjustments;
	editing_tools_adjust_tool_set_adjustments (self, _tmp9_);
	_pixel_transformation_bundle_unref0 (adjustments);
}

static void
editing_tools_adjust_tool_set_adjustments (EditingToolsAdjustTool* self,
                                           PixelTransformationBundle* new_adjustments)
{
	EditingToolsPhotoCanvas* _tmp8_;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (new_adjustments, TYPE_PIXEL_TRANSFORMATION_BUNDLE));
	editing_tools_adjust_tool_unbind_window_handlers (self);
	editing_tools_adjust_tool_update_transformations (self, new_adjustments);
	{
		GeeIterator* _adjustment_it = NULL;
		GeeIterable* _tmp0_;
		GeeIterable* _tmp1_;
		GeeIterator* _tmp2_;
		GeeIterator* _tmp3_;
		_tmp0_ = pixel_transformation_bundle_get_transformations (new_adjustments);
		_tmp1_ = _tmp0_;
		_tmp2_ = gee_iterable_iterator (_tmp1_);
		_tmp3_ = _tmp2_;
		_g_object_unref0 (_tmp1_);
		_adjustment_it = _tmp3_;
		while (TRUE) {
			GeeIterator* _tmp4_;
			PixelTransformation* adjustment = NULL;
			GeeIterator* _tmp5_;
			gpointer _tmp6_;
			PixelTransformation* _tmp7_;
			_tmp4_ = _adjustment_it;
			if (!gee_iterator_next (_tmp4_)) {
				break;
			}
			_tmp5_ = _adjustment_it;
			_tmp6_ = gee_iterator_get (_tmp5_);
			adjustment = (PixelTransformation*) _tmp6_;
			_tmp7_ = adjustment;
			editing_tools_adjust_tool_update_slider (self, _tmp7_);
			_pixel_transformation_unref0 (adjustment);
		}
		_g_object_unref0 (_adjustment_it);
	}
	editing_tools_adjust_tool_bind_window_handlers (self);
	_tmp8_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp8_);
}

static gpointer
_pixel_transformation_ref0 (gpointer self)
{
	return self ? pixel_transformation_ref (self) : NULL;
}

static void
editing_tools_adjust_tool_update_slider (EditingToolsAdjustTool* self,
                                         PixelTransformation* transformation)
{
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (transformation, TYPE_PIXEL_TRANSFORMATION));
	switch (pixel_transformation_get_transformation_type (transformation)) {
		case PIXEL_TRANSFORMATION_TYPE_TONE_EXPANSION:
		{
			ExpansionTransformation* expansion = NULL;
			ExpansionTransformation* _tmp0_;
			_tmp0_ = _pixel_transformation_ref0 (G_TYPE_CHECK_INSTANCE_CAST (transformation, TYPE_EXPANSION_TRANSFORMATION, ExpansionTransformation));
			expansion = _tmp0_;
			if (!self->priv->disable_histogram_refresh) {
				EditingToolsAdjustToolAdjustToolWindow* _tmp1_;
				RGBHistogramManipulator* _tmp2_;
				ExpansionTransformation* _tmp3_;
				EditingToolsAdjustToolAdjustToolWindow* _tmp4_;
				RGBHistogramManipulator* _tmp5_;
				ExpansionTransformation* _tmp6_;
				_tmp1_ = self->priv->adjust_tool_window;
				_tmp2_ = _tmp1_->histogram_manipulator;
				_tmp3_ = expansion;
				rgb_histogram_manipulator_set_left_nub_position (_tmp2_, expansion_transformation_get_black_point (_tmp3_));
				_tmp4_ = self->priv->adjust_tool_window;
				_tmp5_ = _tmp4_->histogram_manipulator;
				_tmp6_ = expansion;
				rgb_histogram_manipulator_set_right_nub_position (_tmp5_, expansion_transformation_get_white_point (_tmp6_));
			}
			_pixel_transformation_unref0 (expansion);
			break;
		}
		case PIXEL_TRANSFORMATION_TYPE_SHADOWS:
		{
			EditingToolsAdjustToolAdjustToolWindow* _tmp7_;
			GtkScale* _tmp8_;
			_tmp7_ = self->priv->adjust_tool_window;
			_tmp8_ = _tmp7_->shadows_slider;
			gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_range_get_type (), GtkRange), (gdouble) shadow_detail_transformation_get_parameter (G_TYPE_CHECK_INSTANCE_CAST (transformation, TYPE_SHADOW_DETAIL_TRANSFORMATION, ShadowDetailTransformation)));
			break;
		}
		case PIXEL_TRANSFORMATION_TYPE_CONTRAST:
		{
			EditingToolsAdjustToolAdjustToolWindow* _tmp9_;
			GtkScale* _tmp10_;
			_tmp9_ = self->priv->adjust_tool_window;
			_tmp10_ = _tmp9_->contrast_slider;
			gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_range_get_type (), GtkRange), (gdouble) contrast_transformation_get_parameter (G_TYPE_CHECK_INSTANCE_CAST (transformation, TYPE_CONTRAST_TRANSFORMATION, ContrastTransformation)));
			break;
		}
		case PIXEL_TRANSFORMATION_TYPE_HIGHLIGHTS:
		{
			EditingToolsAdjustToolAdjustToolWindow* _tmp11_;
			GtkScale* _tmp12_;
			_tmp11_ = self->priv->adjust_tool_window;
			_tmp12_ = _tmp11_->highlights_slider;
			gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_range_get_type (), GtkRange), (gdouble) highlight_detail_transformation_get_parameter (G_TYPE_CHECK_INSTANCE_CAST (transformation, TYPE_HIGHLIGHT_DETAIL_TRANSFORMATION, HighlightDetailTransformation)));
			break;
		}
		case PIXEL_TRANSFORMATION_TYPE_EXPOSURE:
		{
			EditingToolsAdjustToolAdjustToolWindow* _tmp13_;
			GtkScale* _tmp14_;
			_tmp13_ = self->priv->adjust_tool_window;
			_tmp14_ = _tmp13_->exposure_slider;
			gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_range_get_type (), GtkRange), (gdouble) exposure_transformation_get_parameter (G_TYPE_CHECK_INSTANCE_CAST (transformation, TYPE_EXPOSURE_TRANSFORMATION, ExposureTransformation)));
			break;
		}
		case PIXEL_TRANSFORMATION_TYPE_SATURATION:
		{
			EditingToolsAdjustToolAdjustToolWindow* _tmp15_;
			GtkScale* _tmp16_;
			_tmp15_ = self->priv->adjust_tool_window;
			_tmp16_ = _tmp15_->saturation_slider;
			gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_range_get_type (), GtkRange), (gdouble) saturation_transformation_get_parameter (G_TYPE_CHECK_INSTANCE_CAST (transformation, TYPE_SATURATION_TRANSFORMATION, SaturationTransformation)));
			break;
		}
		case PIXEL_TRANSFORMATION_TYPE_TINT:
		{
			EditingToolsAdjustToolAdjustToolWindow* _tmp17_;
			GtkScale* _tmp18_;
			_tmp17_ = self->priv->adjust_tool_window;
			_tmp18_ = _tmp17_->tint_slider;
			gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, gtk_range_get_type (), GtkRange), (gdouble) tint_transformation_get_parameter (G_TYPE_CHECK_INSTANCE_CAST (transformation, TYPE_TINT_TRANSFORMATION, TintTransformation)));
			break;
		}
		case PIXEL_TRANSFORMATION_TYPE_TEMPERATURE:
		{
			EditingToolsAdjustToolAdjustToolWindow* _tmp19_;
			GtkScale* _tmp20_;
			_tmp19_ = self->priv->adjust_tool_window;
			_tmp20_ = _tmp19_->temperature_slider;
			gtk_range_set_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, gtk_range_get_type (), GtkRange), (gdouble) temperature_transformation_get_parameter (G_TYPE_CHECK_INSTANCE_CAST (transformation, TYPE_TEMPERATURE_TRANSFORMATION, TemperatureTransformation)));
			break;
		}
		default:
		{
			g_error ("EditingTools.vala:2954: Unknown adjustment: %d", (gint) pixel_transformation_get_transformation_type (transformation));
		}
	}
}

static void
editing_tools_adjust_tool_init_fp_pixel_cache (EditingToolsAdjustTool* self,
                                               GdkPixbuf* source)
{
	gint source_width = 0;
	gint source_height = 0;
	gint source_num_channels = 0;
	gint source_rowstride = 0;
	guchar* source_pixels = NULL;
	guint8* _tmp0_;
	gint source_pixels_length1;
	gint _source_pixels_size_;
	gfloat* _tmp1_;
	gint cache_pixel_index = 0;
	g_return_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (source, gdk_pixbuf_get_type ()));
	source_width = gdk_pixbuf_get_width (source);
	source_height = gdk_pixbuf_get_height (source);
	source_num_channels = gdk_pixbuf_get_n_channels (source);
	source_rowstride = gdk_pixbuf_get_rowstride (source);
	_tmp0_ = gdk_pixbuf_get_pixels (source);
	source_pixels = _tmp0_;
	source_pixels_length1 = -1;
	_source_pixels_size_ = source_pixels_length1;
	_tmp1_ = g_new0 (gfloat, (3 * source_width) * source_height);
	self->priv->fp_pixel_cache = (g_free (self->priv->fp_pixel_cache), NULL);
	self->priv->fp_pixel_cache = _tmp1_;
	self->priv->fp_pixel_cache_length1 = (3 * source_width) * source_height;
	self->priv->_fp_pixel_cache_size_ = self->priv->fp_pixel_cache_length1;
	cache_pixel_index = 0;
	{
		gint j = 0;
		j = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gint row_start_index = 0;
				gint row_end_index = 0;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = j;
					j = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				if (!(j < source_height)) {
					break;
				}
				row_start_index = j * source_rowstride;
				row_end_index = row_start_index + (source_width * source_num_channels);
				{
					gint i = 0;
					i = row_start_index;
					{
						gboolean _tmp4_ = FALSE;
						_tmp4_ = TRUE;
						while (TRUE) {
							gfloat* _tmp5_;
							gint _tmp5__length1;
							gint _tmp6_;
							guchar* _tmp7_;
							gint _tmp7__length1;
							guchar _tmp8_;
							gfloat _tmp9_;
							gfloat* _tmp10_;
							gint _tmp10__length1;
							gint _tmp11_;
							guchar* _tmp12_;
							gint _tmp12__length1;
							gint _tmp13_;
							guchar _tmp14_;
							gfloat _tmp15_;
							gfloat* _tmp16_;
							gint _tmp16__length1;
							gint _tmp17_;
							guchar* _tmp18_;
							gint _tmp18__length1;
							gint _tmp19_;
							guchar _tmp20_;
							gfloat _tmp21_;
							if (!_tmp4_) {
								i += source_num_channels;
							}
							_tmp4_ = FALSE;
							if (!(i < row_end_index)) {
								break;
							}
							_tmp5_ = self->priv->fp_pixel_cache;
							_tmp5__length1 = self->priv->fp_pixel_cache_length1;
							_tmp6_ = cache_pixel_index;
							cache_pixel_index = _tmp6_ + 1;
							_tmp7_ = source_pixels;
							_tmp7__length1 = source_pixels_length1;
							_tmp8_ = _tmp7_[i];
							_tmp9_ = rgb_lookup_table[_tmp8_];
							_tmp5_[_tmp6_] = _tmp9_;
							_tmp10_ = self->priv->fp_pixel_cache;
							_tmp10__length1 = self->priv->fp_pixel_cache_length1;
							_tmp11_ = cache_pixel_index;
							cache_pixel_index = _tmp11_ + 1;
							_tmp12_ = source_pixels;
							_tmp12__length1 = source_pixels_length1;
							_tmp13_ = i;
							_tmp14_ = _tmp12_[_tmp13_ + 1];
							_tmp15_ = rgb_lookup_table[_tmp14_];
							_tmp10_[_tmp11_] = _tmp15_;
							_tmp16_ = self->priv->fp_pixel_cache;
							_tmp16__length1 = self->priv->fp_pixel_cache_length1;
							_tmp17_ = cache_pixel_index;
							cache_pixel_index = _tmp17_ + 1;
							_tmp18_ = source_pixels;
							_tmp18__length1 = source_pixels_length1;
							_tmp19_ = i;
							_tmp20_ = _tmp18_[_tmp19_ + 2];
							_tmp21_ = rgb_lookup_table[_tmp20_];
							_tmp16_[_tmp17_] = _tmp21_;
						}
					}
				}
			}
		}
	}
}

static gboolean
editing_tools_adjust_tool_real_on_keypress (EditingToolsEditingTool* base,
                                            GdkEventKey* event)
{
	EditingToolsAdjustTool * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustTool);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp2_ = gdk_keyval_name (event->keyval);
	if (g_strcmp0 (_tmp2_, "KP_Enter") == 0) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp3_;
		_tmp3_ = gdk_keyval_name (event->keyval);
		_tmp1_ = g_strcmp0 (_tmp3_, "Enter") == 0;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp4_;
		_tmp4_ = gdk_keyval_name (event->keyval);
		_tmp0_ = g_strcmp0 (_tmp4_, "Return") == 0;
	}
	if (_tmp0_) {
		editing_tools_adjust_tool_on_ok (self);
		result = TRUE;
		return result;
	}
	result = EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_adjust_tool_parent_class)->on_keypress (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), event);
	return result;
}

static EditingToolsAdjustToolAdjustToolWindow*
editing_tools_adjust_tool_adjust_tool_window_construct (GType object_type,
                                                        GtkWindow* container)
{
	EditingToolsAdjustToolAdjustToolWindow * self = NULL;
	GtkGrid* slider_organizer = NULL;
	GtkGrid* _tmp0_;
	GtkLabel* exposure_label = NULL;
	GtkLabel* _tmp1_;
	GtkScale* _tmp2_;
	GtkScale* _tmp3_;
	GtkScale* _tmp4_;
	GtkScale* _tmp5_;
	GtkLabel* contrast_label = NULL;
	GtkLabel* _tmp6_;
	GtkScale* _tmp7_;
	GtkScale* _tmp8_;
	GtkScale* _tmp9_;
	GtkScale* _tmp10_;
	GtkLabel* saturation_label = NULL;
	GtkLabel* _tmp11_;
	GtkScale* _tmp12_;
	GtkScale* _tmp13_;
	GtkScale* _tmp14_;
	GtkScale* _tmp15_;
	GtkLabel* tint_label = NULL;
	GtkLabel* _tmp16_;
	GtkScale* _tmp17_;
	GtkScale* _tmp18_;
	GtkScale* _tmp19_;
	GtkScale* _tmp20_;
	GtkLabel* temperature_label = NULL;
	GtkLabel* _tmp21_;
	GtkScale* _tmp22_;
	GtkScale* _tmp23_;
	GtkScale* _tmp24_;
	GtkScale* _tmp25_;
	GtkLabel* shadows_label = NULL;
	GtkLabel* _tmp26_;
	GtkScale* _tmp27_;
	GtkScale* _tmp28_;
	GtkScale* _tmp29_;
	GtkScale* _tmp30_;
	GtkLabel* highlights_label = NULL;
	GtkLabel* _tmp31_;
	GtkScale* _tmp32_;
	GtkScale* _tmp33_;
	GtkScale* _tmp34_;
	GtkScale* _tmp35_;
	GtkBox* button_layouter = NULL;
	GtkBox* _tmp36_;
	GtkButton* _tmp37_;
	GtkButton* _tmp38_;
	GtkButton* _tmp39_;
	RGBHistogramManipulator* _tmp40_;
	RGBHistogramManipulator* _tmp41_;
	RGBHistogramManipulator* _tmp42_;
	RGBHistogramManipulator* _tmp43_;
	GtkBox* pane_layouter = NULL;
	GtkBox* _tmp44_;
	RGBHistogramManipulator* _tmp45_;
	RGBHistogramManipulator* _tmp46_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (container, gtk_window_get_type ()), NULL);
	self = (EditingToolsAdjustToolAdjustToolWindow*) editing_tools_editing_tool_window_construct (object_type, container);
	_tmp0_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp0_);
	slider_organizer = _tmp0_;
	gtk_grid_set_column_homogeneous (slider_organizer, FALSE);
	gtk_grid_set_row_spacing (slider_organizer, (guint) 12);
	gtk_grid_set_column_spacing (slider_organizer, (guint) 12);
	gtk_widget_set_margin_start (G_TYPE_CHECK_INSTANCE_CAST (slider_organizer, gtk_widget_get_type (), GtkWidget), 12);
	gtk_widget_set_margin_bottom (G_TYPE_CHECK_INSTANCE_CAST (slider_organizer, gtk_widget_get_type (), GtkWidget), 12);
	_tmp1_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Exposure:"));
	g_object_ref_sink (_tmp1_);
	exposure_label = _tmp1_;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (exposure_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (exposure_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (exposure_label, gtk_widget_get_type (), GtkWidget), 0, 0, 1, 1);
	_tmp2_ = self->exposure_slider;
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_widget_get_type (), GtkWidget), 1, 0, 1, 1);
	_tmp3_ = self->exposure_slider;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget), EDITING_TOOLS_ADJUST_TOOL_SLIDER_WIDTH, -1);
	_tmp4_ = self->exposure_slider;
	gtk_scale_set_value_pos (_tmp4_, GTK_POS_RIGHT);
	_tmp5_ = self->exposure_slider;
	gtk_widget_set_margin_end (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_widget_get_type (), GtkWidget), 0);
	_tmp6_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Contrast:"));
	g_object_ref_sink (_tmp6_);
	contrast_label = _tmp6_;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (contrast_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (contrast_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (contrast_label, gtk_widget_get_type (), GtkWidget), 0, 1, 1, 1);
	_tmp7_ = self->contrast_slider;
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget), 1, 1, 1, 1);
	_tmp8_ = self->contrast_slider;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_widget_get_type (), GtkWidget), EDITING_TOOLS_ADJUST_TOOL_SLIDER_WIDTH, -1);
	_tmp9_ = self->contrast_slider;
	gtk_scale_set_value_pos (_tmp9_, GTK_POS_RIGHT);
	_tmp10_ = self->contrast_slider;
	gtk_widget_set_margin_end (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_widget_get_type (), GtkWidget), 0);
	_tmp11_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Saturation:"));
	g_object_ref_sink (_tmp11_);
	saturation_label = _tmp11_;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (saturation_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (saturation_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (saturation_label, gtk_widget_get_type (), GtkWidget), 0, 2, 1, 1);
	_tmp12_ = self->saturation_slider;
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget), 1, 2, 1, 1);
	_tmp13_ = self->saturation_slider;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_widget_get_type (), GtkWidget), EDITING_TOOLS_ADJUST_TOOL_SLIDER_WIDTH, -1);
	_tmp14_ = self->saturation_slider;
	gtk_scale_set_value_pos (_tmp14_, GTK_POS_RIGHT);
	_tmp15_ = self->saturation_slider;
	gtk_widget_set_margin_end (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_widget_get_type (), GtkWidget), 0);
	_tmp16_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Tint:"));
	g_object_ref_sink (_tmp16_);
	tint_label = _tmp16_;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (tint_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (tint_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (tint_label, gtk_widget_get_type (), GtkWidget), 0, 3, 1, 1);
	_tmp17_ = self->tint_slider;
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, gtk_widget_get_type (), GtkWidget), 1, 3, 1, 1);
	_tmp18_ = self->tint_slider;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, gtk_widget_get_type (), GtkWidget), EDITING_TOOLS_ADJUST_TOOL_SLIDER_WIDTH, -1);
	_tmp19_ = self->tint_slider;
	gtk_scale_set_value_pos (_tmp19_, GTK_POS_RIGHT);
	_tmp20_ = self->tint_slider;
	gtk_widget_set_margin_end (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, gtk_widget_get_type (), GtkWidget), 0);
	_tmp21_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Temperature:"));
	g_object_ref_sink (_tmp21_);
	temperature_label = _tmp21_;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (temperature_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (temperature_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (temperature_label, gtk_widget_get_type (), GtkWidget), 0, 4, 1, 1);
	_tmp22_ = self->temperature_slider;
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, gtk_widget_get_type (), GtkWidget), 1, 4, 1, 1);
	_tmp23_ = self->temperature_slider;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, gtk_widget_get_type (), GtkWidget), EDITING_TOOLS_ADJUST_TOOL_SLIDER_WIDTH, -1);
	_tmp24_ = self->temperature_slider;
	gtk_scale_set_value_pos (_tmp24_, GTK_POS_RIGHT);
	_tmp25_ = self->temperature_slider;
	gtk_widget_set_margin_end (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gtk_widget_get_type (), GtkWidget), 0);
	_tmp26_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Shadows:"));
	g_object_ref_sink (_tmp26_);
	shadows_label = _tmp26_;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (shadows_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (shadows_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (shadows_label, gtk_widget_get_type (), GtkWidget), 0, 5, 1, 1);
	_tmp27_ = self->shadows_slider;
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, gtk_widget_get_type (), GtkWidget), 1, 5, 1, 1);
	_tmp28_ = self->shadows_slider;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, gtk_widget_get_type (), GtkWidget), EDITING_TOOLS_ADJUST_TOOL_SLIDER_WIDTH, -1);
	_tmp29_ = self->shadows_slider;
	gtk_scale_set_value_pos (_tmp29_, GTK_POS_RIGHT);
	_tmp30_ = self->shadows_slider;
	gtk_widget_set_margin_end (G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, gtk_widget_get_type (), GtkWidget), 5);
	_tmp31_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Highlights:"));
	g_object_ref_sink (_tmp31_);
	highlights_label = _tmp31_;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (highlights_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (highlights_label, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (highlights_label, gtk_widget_get_type (), GtkWidget), 0, 6, 1, 1);
	_tmp32_ = self->highlights_slider;
	gtk_grid_attach (slider_organizer, G_TYPE_CHECK_INSTANCE_CAST (_tmp32_, gtk_widget_get_type (), GtkWidget), 1, 6, 1, 1);
	_tmp33_ = self->highlights_slider;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp33_, gtk_widget_get_type (), GtkWidget), EDITING_TOOLS_ADJUST_TOOL_SLIDER_WIDTH, -1);
	_tmp34_ = self->highlights_slider;
	gtk_scale_set_value_pos (_tmp34_, GTK_POS_RIGHT);
	_tmp35_ = self->highlights_slider;
	gtk_widget_set_margin_end (G_TYPE_CHECK_INSTANCE_CAST (_tmp35_, gtk_widget_get_type (), GtkWidget), 0);
	_tmp36_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp36_);
	button_layouter = _tmp36_;
	gtk_box_set_homogeneous (button_layouter, TRUE);
	_tmp37_ = self->cancel_button;
	gtk_box_pack_start (button_layouter, G_TYPE_CHECK_INSTANCE_CAST (_tmp37_, gtk_widget_get_type (), GtkWidget), TRUE, TRUE, (guint) 1);
	_tmp38_ = self->reset_button;
	gtk_box_pack_start (button_layouter, G_TYPE_CHECK_INSTANCE_CAST (_tmp38_, gtk_widget_get_type (), GtkWidget), TRUE, TRUE, (guint) 1);
	_tmp39_ = self->ok_button;
	gtk_box_pack_start (button_layouter, G_TYPE_CHECK_INSTANCE_CAST (_tmp39_, gtk_widget_get_type (), GtkWidget), TRUE, TRUE, (guint) 1);
	_tmp40_ = self->histogram_manipulator;
	gtk_widget_set_margin_start (G_TYPE_CHECK_INSTANCE_CAST (_tmp40_, gtk_widget_get_type (), GtkWidget), 12);
	_tmp41_ = self->histogram_manipulator;
	gtk_widget_set_margin_end (G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, gtk_widget_get_type (), GtkWidget), 12);
	_tmp42_ = self->histogram_manipulator;
	gtk_widget_set_margin_top (G_TYPE_CHECK_INSTANCE_CAST (_tmp42_, gtk_widget_get_type (), GtkWidget), 12);
	_tmp43_ = self->histogram_manipulator;
	gtk_widget_set_margin_bottom (G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, gtk_widget_get_type (), GtkWidget), 8);
	_tmp44_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	g_object_ref_sink (_tmp44_);
	pane_layouter = _tmp44_;
	_tmp45_ = self->histogram_manipulator;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (pane_layouter, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp45_, gtk_widget_get_type (), GtkWidget));
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (pane_layouter, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (slider_organizer, gtk_widget_get_type (), GtkWidget));
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (pane_layouter, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (button_layouter, gtk_widget_get_type (), GtkWidget));
	_tmp46_ = self->histogram_manipulator;
	gtk_box_set_child_packing (pane_layouter, G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0, GTK_PACK_START);
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (pane_layouter, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (pane_layouter);
	_g_object_unref0 (button_layouter);
	_g_object_unref0 (highlights_label);
	_g_object_unref0 (shadows_label);
	_g_object_unref0 (temperature_label);
	_g_object_unref0 (tint_label);
	_g_object_unref0 (saturation_label);
	_g_object_unref0 (contrast_label);
	_g_object_unref0 (exposure_label);
	_g_object_unref0 (slider_organizer);
	return self;
}

static EditingToolsAdjustToolAdjustToolWindow*
editing_tools_adjust_tool_adjust_tool_window_new (GtkWindow* container)
{
	return editing_tools_adjust_tool_adjust_tool_window_construct (EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_WINDOW, container);
}

static void
editing_tools_adjust_tool_adjust_tool_window_class_init (EditingToolsAdjustToolAdjustToolWindowClass * klass,
                                                         gpointer klass_data)
{
	editing_tools_adjust_tool_adjust_tool_window_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = editing_tools_adjust_tool_adjust_tool_window_finalize;
}

static void
editing_tools_adjust_tool_adjust_tool_window_instance_init (EditingToolsAdjustToolAdjustToolWindow * self,
                                                            gpointer klass)
{
	GtkScale* _tmp0_;
	GtkScale* _tmp1_;
	GtkScale* _tmp2_;
	GtkScale* _tmp3_;
	GtkScale* _tmp4_;
	GtkScale* _tmp5_;
	GtkScale* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	GtkButton* _tmp9_;
	RGBHistogramManipulator* _tmp10_;
	_tmp0_ = (GtkScale*) gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, (gdouble) EXPOSURE_TRANSFORMATION_MIN_PARAMETER, (gdouble) EXPOSURE_TRANSFORMATION_MAX_PARAMETER, 1.0);
	g_object_ref_sink (_tmp0_);
	self->exposure_slider = _tmp0_;
	_tmp1_ = (GtkScale*) gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, (gdouble) CONTRAST_TRANSFORMATION_MIN_PARAMETER, (gdouble) CONTRAST_TRANSFORMATION_MAX_PARAMETER, 1.0);
	g_object_ref_sink (_tmp1_);
	self->contrast_slider = _tmp1_;
	_tmp2_ = (GtkScale*) gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, (gdouble) SATURATION_TRANSFORMATION_MIN_PARAMETER, (gdouble) SATURATION_TRANSFORMATION_MAX_PARAMETER, 1.0);
	g_object_ref_sink (_tmp2_);
	self->saturation_slider = _tmp2_;
	_tmp3_ = (GtkScale*) gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, (gdouble) TINT_TRANSFORMATION_MIN_PARAMETER, (gdouble) TINT_TRANSFORMATION_MAX_PARAMETER, 1.0);
	g_object_ref_sink (_tmp3_);
	self->tint_slider = _tmp3_;
	_tmp4_ = (GtkScale*) gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, (gdouble) TEMPERATURE_TRANSFORMATION_MIN_PARAMETER, (gdouble) TEMPERATURE_TRANSFORMATION_MAX_PARAMETER, 1.0);
	g_object_ref_sink (_tmp4_);
	self->temperature_slider = _tmp4_;
	_tmp5_ = (GtkScale*) gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, (gdouble) SHADOW_DETAIL_TRANSFORMATION_MIN_PARAMETER, (gdouble) SHADOW_DETAIL_TRANSFORMATION_MAX_PARAMETER, 1.0);
	g_object_ref_sink (_tmp5_);
	self->shadows_slider = _tmp5_;
	_tmp6_ = (GtkScale*) gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, (gdouble) HIGHLIGHT_DETAIL_TRANSFORMATION_MIN_PARAMETER, (gdouble) HIGHLIGHT_DETAIL_TRANSFORMATION_MAX_PARAMETER, 1.0);
	g_object_ref_sink (_tmp6_);
	self->highlights_slider = _tmp6_;
	_tmp7_ = (GtkButton*) gtk_button_new_with_mnemonic (RESOURCES_OK_LABEL);
	g_object_ref_sink (_tmp7_);
	self->ok_button = _tmp7_;
	_tmp8_ = (GtkButton*) gtk_button_new_with_mnemonic (_ ("_Reset"));
	g_object_ref_sink (_tmp8_);
	self->reset_button = _tmp8_;
	_tmp9_ = (GtkButton*) gtk_button_new_with_mnemonic (RESOURCES_CANCEL_LABEL);
	g_object_ref_sink (_tmp9_);
	self->cancel_button = _tmp9_;
	_tmp10_ = rgb_histogram_manipulator_new ();
	g_object_ref_sink (_tmp10_);
	self->histogram_manipulator = _tmp10_;
}

static void
editing_tools_adjust_tool_adjust_tool_window_finalize (GObject * obj)
{
	EditingToolsAdjustToolAdjustToolWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_WINDOW, EditingToolsAdjustToolAdjustToolWindow);
	_g_object_unref0 (self->exposure_slider);
	_g_object_unref0 (self->contrast_slider);
	_g_object_unref0 (self->saturation_slider);
	_g_object_unref0 (self->tint_slider);
	_g_object_unref0 (self->temperature_slider);
	_g_object_unref0 (self->shadows_slider);
	_g_object_unref0 (self->highlights_slider);
	_g_object_unref0 (self->ok_button);
	_g_object_unref0 (self->reset_button);
	_g_object_unref0 (self->cancel_button);
	_g_object_unref0 (self->histogram_manipulator);
	G_OBJECT_CLASS (editing_tools_adjust_tool_adjust_tool_window_parent_class)->finalize (obj);
}

static GType
editing_tools_adjust_tool_adjust_tool_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsAdjustToolAdjustToolWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_adjust_tool_adjust_tool_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsAdjustToolAdjustToolWindow), 0, (GInstanceInitFunc) editing_tools_adjust_tool_adjust_tool_window_instance_init, NULL };
	GType editing_tools_adjust_tool_adjust_tool_window_type_id;
	editing_tools_adjust_tool_adjust_tool_window_type_id = g_type_register_static (EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, "EditingToolsAdjustToolAdjustToolWindow", &g_define_type_info, 0);
	return editing_tools_adjust_tool_adjust_tool_window_type_id;
}

static GType
editing_tools_adjust_tool_adjust_tool_window_get_type (void)
{
	static volatile gsize editing_tools_adjust_tool_adjust_tool_window_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_adjust_tool_adjust_tool_window_type_id__once)) {
		GType editing_tools_adjust_tool_adjust_tool_window_type_id;
		editing_tools_adjust_tool_adjust_tool_window_type_id = editing_tools_adjust_tool_adjust_tool_window_get_type_once ();
		g_once_init_leave (&editing_tools_adjust_tool_adjust_tool_window_type_id__once, editing_tools_adjust_tool_adjust_tool_window_type_id);
	}
	return editing_tools_adjust_tool_adjust_tool_window_type_id__once;
}

static void
_editing_tools_adjust_tool_adjust_tool_command_on_owner_deactivated_editing_tools_editing_tool_deactivated (EditingToolsEditingTool* _sender,
                                                                                                            gpointer self)
{
	editing_tools_adjust_tool_adjust_tool_command_on_owner_deactivated ((EditingToolsAdjustToolAdjustToolCommand*) self);
}

static EditingToolsAdjustToolAdjustToolCommand*
editing_tools_adjust_tool_adjust_tool_command_construct (GType object_type,
                                                         EditingToolsAdjustTool* owner,
                                                         const gchar* name,
                                                         const gchar* explanation)
{
	EditingToolsAdjustToolAdjustToolCommand * self = NULL;
	g_return_val_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (owner), NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (explanation != NULL, NULL);
	self = (EditingToolsAdjustToolAdjustToolCommand*) command_construct (object_type, name, explanation);
	self->owner = owner;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (owner, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), "deactivated", (GCallback) _editing_tools_adjust_tool_adjust_tool_command_on_owner_deactivated_editing_tools_editing_tool_deactivated, self, 0);
	return self;
}

static void
editing_tools_adjust_tool_adjust_tool_command_on_owner_deactivated (EditingToolsAdjustToolAdjustToolCommand* self)
{
	CommandManager* _tmp0_;
	CommandManager* _tmp1_;
	g_return_if_fail (EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_TOOL_COMMAND (self));
	_tmp0_ = app_window_get_command_manager ();
	_tmp1_ = _tmp0_;
	command_manager_reset (_tmp1_);
	_command_manager_unref0 (_tmp1_);
}

static void
editing_tools_adjust_tool_adjust_tool_command_class_init (EditingToolsAdjustToolAdjustToolCommandClass * klass,
                                                          gpointer klass_data)
{
	editing_tools_adjust_tool_adjust_tool_command_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = editing_tools_adjust_tool_adjust_tool_command_finalize;
}

static void
editing_tools_adjust_tool_adjust_tool_command_instance_init (EditingToolsAdjustToolAdjustToolCommand * self,
                                                             gpointer klass)
{
}

static void
editing_tools_adjust_tool_adjust_tool_command_finalize (GObject * obj)
{
	EditingToolsAdjustToolAdjustToolCommand * self;
	EditingToolsAdjustTool* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand);
	_tmp0_ = self->owner;
	if (_tmp0_ != NULL) {
		EditingToolsAdjustTool* _tmp1_;
		guint _tmp2_;
		_tmp1_ = self->owner;
		g_signal_parse_name ("deactivated", EDITING_TOOLS_TYPE_EDITING_TOOL, &_tmp2_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _editing_tools_adjust_tool_adjust_tool_command_on_owner_deactivated_editing_tools_editing_tool_deactivated, self);
	}
	G_OBJECT_CLASS (editing_tools_adjust_tool_adjust_tool_command_parent_class)->finalize (obj);
}

static GType
editing_tools_adjust_tool_adjust_tool_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsAdjustToolAdjustToolCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_adjust_tool_adjust_tool_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsAdjustToolAdjustToolCommand), 0, (GInstanceInitFunc) editing_tools_adjust_tool_adjust_tool_command_instance_init, NULL };
	GType editing_tools_adjust_tool_adjust_tool_command_type_id;
	editing_tools_adjust_tool_adjust_tool_command_type_id = g_type_register_static (TYPE_COMMAND, "EditingToolsAdjustToolAdjustToolCommand", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return editing_tools_adjust_tool_adjust_tool_command_type_id;
}

static GType
editing_tools_adjust_tool_adjust_tool_command_get_type (void)
{
	static volatile gsize editing_tools_adjust_tool_adjust_tool_command_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_adjust_tool_adjust_tool_command_type_id__once)) {
		GType editing_tools_adjust_tool_adjust_tool_command_type_id;
		editing_tools_adjust_tool_adjust_tool_command_type_id = editing_tools_adjust_tool_adjust_tool_command_get_type_once ();
		g_once_init_leave (&editing_tools_adjust_tool_adjust_tool_command_type_id__once, editing_tools_adjust_tool_adjust_tool_command_type_id);
	}
	return editing_tools_adjust_tool_adjust_tool_command_type_id__once;
}

static inline gpointer
editing_tools_adjust_tool_adjust_reset_command_get_instance_private (EditingToolsAdjustToolAdjustResetCommand* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsAdjustToolAdjustResetCommand_private_offset);
}

static EditingToolsAdjustToolAdjustResetCommand*
editing_tools_adjust_tool_adjust_reset_command_construct (GType object_type,
                                                          EditingToolsAdjustTool* owner,
                                                          PixelTransformationBundle* current)
{
	EditingToolsAdjustToolAdjustResetCommand * self = NULL;
	PixelTransformationBundle* _tmp0_;
	PixelTransformationBundle* _tmp1_;
	PixelTransformationBundle* _tmp2_;
	g_return_val_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (owner), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (current, TYPE_PIXEL_TRANSFORMATION_BUNDLE), NULL);
	self = (EditingToolsAdjustToolAdjustResetCommand*) editing_tools_adjust_tool_adjust_tool_command_construct (object_type, owner, _ ("Reset Colors"), _ ("Reset all color adjustments to original"));
	_tmp0_ = pixel_transformation_bundle_copy (current);
	_pixel_transformation_bundle_unref0 (self->priv->original);
	self->priv->original = _tmp0_;
	_tmp1_ = pixel_transformation_bundle_new ();
	_pixel_transformation_bundle_unref0 (self->priv->reset);
	self->priv->reset = _tmp1_;
	_tmp2_ = self->priv->reset;
	pixel_transformation_bundle_set_to_identity (_tmp2_);
	return self;
}

static EditingToolsAdjustToolAdjustResetCommand*
editing_tools_adjust_tool_adjust_reset_command_new (EditingToolsAdjustTool* owner,
                                                    PixelTransformationBundle* current)
{
	return editing_tools_adjust_tool_adjust_reset_command_construct (EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND, owner, current);
}

static void
editing_tools_adjust_tool_adjust_reset_command_real_execute (Command* base)
{
	EditingToolsAdjustToolAdjustResetCommand * self;
	EditingToolsAdjustTool* _tmp0_;
	PixelTransformationBundle* _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND, EditingToolsAdjustToolAdjustResetCommand);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp1_ = self->priv->reset;
	editing_tools_adjust_tool_set_adjustments (_tmp0_, _tmp1_);
}

static void
editing_tools_adjust_tool_adjust_reset_command_real_undo (Command* base)
{
	EditingToolsAdjustToolAdjustResetCommand * self;
	EditingToolsAdjustTool* _tmp0_;
	PixelTransformationBundle* _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND, EditingToolsAdjustToolAdjustResetCommand);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp1_ = self->priv->original;
	editing_tools_adjust_tool_set_adjustments (_tmp0_, _tmp1_);
}

static gboolean
editing_tools_adjust_tool_adjust_reset_command_real_compress (Command* base,
                                                              Command* command)
{
	EditingToolsAdjustToolAdjustResetCommand * self;
	EditingToolsAdjustToolAdjustResetCommand* reset_command = NULL;
	EditingToolsAdjustToolAdjustResetCommand* _tmp0_;
	EditingToolsAdjustToolAdjustResetCommand* _tmp1_;
	EditingToolsAdjustToolAdjustResetCommand* _tmp2_;
	EditingToolsAdjustTool* _tmp3_;
	EditingToolsAdjustTool* _tmp4_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND, EditingToolsAdjustToolAdjustResetCommand);
	g_return_val_if_fail (IS_COMMAND (command), FALSE);
	_tmp0_ = _g_object_ref0 (EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_RESET_COMMAND (command) ? ((EditingToolsAdjustToolAdjustResetCommand*) command) : NULL);
	reset_command = _tmp0_;
	_tmp1_ = reset_command;
	if (_tmp1_ == NULL) {
		result = FALSE;
		_g_object_unref0 (reset_command);
		return result;
	}
	_tmp2_ = reset_command;
	_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	if (_tmp3_ != _tmp4_) {
		result = FALSE;
		_g_object_unref0 (reset_command);
		return result;
	}
	result = TRUE;
	_g_object_unref0 (reset_command);
	return result;
}

static void
editing_tools_adjust_tool_adjust_reset_command_class_init (EditingToolsAdjustToolAdjustResetCommandClass * klass,
                                                           gpointer klass_data)
{
	editing_tools_adjust_tool_adjust_reset_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &EditingToolsAdjustToolAdjustResetCommand_private_offset);
	((CommandClass *) klass)->execute = (void (*) (Command*)) editing_tools_adjust_tool_adjust_reset_command_real_execute;
	((CommandClass *) klass)->undo = (void (*) (Command*)) editing_tools_adjust_tool_adjust_reset_command_real_undo;
	((CommandClass *) klass)->compress = (gboolean (*) (Command*, Command*)) editing_tools_adjust_tool_adjust_reset_command_real_compress;
	G_OBJECT_CLASS (klass)->finalize = editing_tools_adjust_tool_adjust_reset_command_finalize;
}

static void
editing_tools_adjust_tool_adjust_reset_command_instance_init (EditingToolsAdjustToolAdjustResetCommand * self,
                                                              gpointer klass)
{
	self->priv = editing_tools_adjust_tool_adjust_reset_command_get_instance_private (self);
}

static void
editing_tools_adjust_tool_adjust_reset_command_finalize (GObject * obj)
{
	EditingToolsAdjustToolAdjustResetCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_RESET_COMMAND, EditingToolsAdjustToolAdjustResetCommand);
	_pixel_transformation_bundle_unref0 (self->priv->original);
	_pixel_transformation_bundle_unref0 (self->priv->reset);
	G_OBJECT_CLASS (editing_tools_adjust_tool_adjust_reset_command_parent_class)->finalize (obj);
}

static GType
editing_tools_adjust_tool_adjust_reset_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsAdjustToolAdjustResetCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_adjust_tool_adjust_reset_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsAdjustToolAdjustResetCommand), 0, (GInstanceInitFunc) editing_tools_adjust_tool_adjust_reset_command_instance_init, NULL };
	GType editing_tools_adjust_tool_adjust_reset_command_type_id;
	editing_tools_adjust_tool_adjust_reset_command_type_id = g_type_register_static (EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, "EditingToolsAdjustToolAdjustResetCommand", &g_define_type_info, 0);
	EditingToolsAdjustToolAdjustResetCommand_private_offset = g_type_add_instance_private (editing_tools_adjust_tool_adjust_reset_command_type_id, sizeof (EditingToolsAdjustToolAdjustResetCommandPrivate));
	return editing_tools_adjust_tool_adjust_reset_command_type_id;
}

static GType
editing_tools_adjust_tool_adjust_reset_command_get_type (void)
{
	static volatile gsize editing_tools_adjust_tool_adjust_reset_command_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_adjust_tool_adjust_reset_command_type_id__once)) {
		GType editing_tools_adjust_tool_adjust_reset_command_type_id;
		editing_tools_adjust_tool_adjust_reset_command_type_id = editing_tools_adjust_tool_adjust_reset_command_get_type_once ();
		g_once_init_leave (&editing_tools_adjust_tool_adjust_reset_command_type_id__once, editing_tools_adjust_tool_adjust_reset_command_type_id);
	}
	return editing_tools_adjust_tool_adjust_reset_command_type_id__once;
}

static inline gpointer
editing_tools_adjust_tool_slider_adjustment_command_get_instance_private (EditingToolsAdjustToolSliderAdjustmentCommand* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsAdjustToolSliderAdjustmentCommand_private_offset);
}

static EditingToolsAdjustToolSliderAdjustmentCommand*
editing_tools_adjust_tool_slider_adjustment_command_construct (GType object_type,
                                                               EditingToolsAdjustTool* owner,
                                                               PixelTransformation* old_transformation,
                                                               PixelTransformation* new_transformation,
                                                               const gchar* name)
{
	EditingToolsAdjustToolSliderAdjustmentCommand * self = NULL;
	PixelTransformation* _tmp0_;
	PixelTransformation* _tmp1_;
	g_return_val_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (owner), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (old_transformation, TYPE_PIXEL_TRANSFORMATION), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (new_transformation, TYPE_PIXEL_TRANSFORMATION), NULL);
	g_return_val_if_fail (name != NULL, NULL);
	self = (EditingToolsAdjustToolSliderAdjustmentCommand*) editing_tools_adjust_tool_adjust_tool_command_construct (object_type, owner, name, name);
	_tmp0_ = _pixel_transformation_ref0 (old_transformation);
	_pixel_transformation_unref0 (self->priv->old_transformation);
	self->priv->old_transformation = _tmp0_;
	_tmp1_ = _pixel_transformation_ref0 (new_transformation);
	_pixel_transformation_unref0 (self->priv->new_transformation);
	self->priv->new_transformation = _tmp1_;
	self->priv->transformation_type = pixel_transformation_get_transformation_type (old_transformation);
	_vala_assert (pixel_transformation_get_transformation_type (new_transformation) == self->priv->transformation_type, "new_transformation.get_transformation_type() == transformation_type");
	return self;
}

static EditingToolsAdjustToolSliderAdjustmentCommand*
editing_tools_adjust_tool_slider_adjustment_command_new (EditingToolsAdjustTool* owner,
                                                         PixelTransformation* old_transformation,
                                                         PixelTransformation* new_transformation,
                                                         const gchar* name)
{
	return editing_tools_adjust_tool_slider_adjustment_command_construct (EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND, owner, old_transformation, new_transformation, name);
}

static void
editing_tools_adjust_tool_slider_adjustment_command_real_execute (Command* base)
{
	EditingToolsAdjustToolSliderAdjustmentCommand * self;
	EditingToolsAdjustTool* _tmp0_;
	PixelTransformation* _tmp1_;
	EditingToolsAdjustTool* _tmp2_;
	EditingToolsPhotoCanvas* _tmp3_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND, EditingToolsAdjustToolSliderAdjustmentCommand);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp1_ = self->priv->new_transformation;
	editing_tools_adjust_tool_update_transformation (_tmp0_, _tmp1_);
	_tmp2_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp3_);
}

static void
editing_tools_adjust_tool_slider_adjustment_command_real_undo (Command* base)
{
	EditingToolsAdjustToolSliderAdjustmentCommand * self;
	EditingToolsAdjustTool* _tmp0_;
	PixelTransformation* _tmp1_;
	EditingToolsAdjustTool* _tmp2_;
	EditingToolsAdjustTool* _tmp3_;
	PixelTransformation* _tmp4_;
	EditingToolsAdjustTool* _tmp5_;
	EditingToolsAdjustTool* _tmp6_;
	EditingToolsPhotoCanvas* _tmp7_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND, EditingToolsAdjustToolSliderAdjustmentCommand);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp1_ = self->priv->old_transformation;
	editing_tools_adjust_tool_update_transformation (_tmp0_, _tmp1_);
	_tmp2_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	editing_tools_adjust_tool_unbind_window_handlers (_tmp2_);
	_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp4_ = self->priv->old_transformation;
	editing_tools_adjust_tool_update_slider (_tmp3_, _tmp4_);
	_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	editing_tools_adjust_tool_bind_window_handlers (_tmp5_);
	_tmp6_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp7_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp7_);
}

static void
editing_tools_adjust_tool_slider_adjustment_command_real_redo (Command* base)
{
	EditingToolsAdjustToolSliderAdjustmentCommand * self;
	EditingToolsAdjustTool* _tmp0_;
	PixelTransformation* _tmp1_;
	EditingToolsAdjustTool* _tmp2_;
	EditingToolsAdjustTool* _tmp3_;
	PixelTransformation* _tmp4_;
	EditingToolsAdjustTool* _tmp5_;
	EditingToolsAdjustTool* _tmp6_;
	EditingToolsPhotoCanvas* _tmp7_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND, EditingToolsAdjustToolSliderAdjustmentCommand);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp1_ = self->priv->new_transformation;
	editing_tools_adjust_tool_update_transformation (_tmp0_, _tmp1_);
	_tmp2_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	editing_tools_adjust_tool_unbind_window_handlers (_tmp2_);
	_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp4_ = self->priv->new_transformation;
	editing_tools_adjust_tool_update_slider (_tmp3_, _tmp4_);
	_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	editing_tools_adjust_tool_bind_window_handlers (_tmp5_);
	_tmp6_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp7_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	editing_tools_photo_canvas_repaint (_tmp7_);
}

static gboolean
editing_tools_adjust_tool_slider_adjustment_command_real_compress (Command* base,
                                                                   Command* command)
{
	EditingToolsAdjustToolSliderAdjustmentCommand * self;
	EditingToolsAdjustToolSliderAdjustmentCommand* slider_adjustment = NULL;
	EditingToolsAdjustToolSliderAdjustmentCommand* _tmp0_;
	EditingToolsAdjustToolSliderAdjustmentCommand* _tmp1_;
	EditingToolsAdjustToolSliderAdjustmentCommand* _tmp2_;
	EditingToolsAdjustTool* _tmp3_;
	EditingToolsAdjustTool* _tmp4_;
	EditingToolsAdjustToolSliderAdjustmentCommand* _tmp5_;
	EditingToolsAdjustToolSliderAdjustmentCommand* _tmp6_;
	EditingToolsAdjustToolSliderAdjustmentCommand* _tmp7_;
	PixelTransformation* _tmp8_;
	PixelTransformation* _tmp9_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND, EditingToolsAdjustToolSliderAdjustmentCommand);
	g_return_val_if_fail (IS_COMMAND (command), FALSE);
	_tmp0_ = _g_object_ref0 (EDITING_TOOLS_ADJUST_TOOL_IS_SLIDER_ADJUSTMENT_COMMAND (command) ? ((EditingToolsAdjustToolSliderAdjustmentCommand*) command) : NULL);
	slider_adjustment = _tmp0_;
	_tmp1_ = slider_adjustment;
	if (_tmp1_ == NULL) {
		result = FALSE;
		_g_object_unref0 (slider_adjustment);
		return result;
	}
	_tmp2_ = slider_adjustment;
	_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp4_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	if (_tmp3_ != _tmp4_) {
		result = FALSE;
		_g_object_unref0 (slider_adjustment);
		return result;
	}
	_tmp5_ = slider_adjustment;
	if (_tmp5_->priv->transformation_type != self->priv->transformation_type) {
		result = FALSE;
		_g_object_unref0 (slider_adjustment);
		return result;
	}
	_tmp6_ = slider_adjustment;
	command_execute (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, TYPE_COMMAND, Command));
	_tmp7_ = slider_adjustment;
	_tmp8_ = _tmp7_->priv->new_transformation;
	_tmp9_ = _pixel_transformation_ref0 (_tmp8_);
	_pixel_transformation_unref0 (self->priv->new_transformation);
	self->priv->new_transformation = _tmp9_;
	result = TRUE;
	_g_object_unref0 (slider_adjustment);
	return result;
}

static void
editing_tools_adjust_tool_slider_adjustment_command_class_init (EditingToolsAdjustToolSliderAdjustmentCommandClass * klass,
                                                                gpointer klass_data)
{
	editing_tools_adjust_tool_slider_adjustment_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &EditingToolsAdjustToolSliderAdjustmentCommand_private_offset);
	((CommandClass *) klass)->execute = (void (*) (Command*)) editing_tools_adjust_tool_slider_adjustment_command_real_execute;
	((CommandClass *) klass)->undo = (void (*) (Command*)) editing_tools_adjust_tool_slider_adjustment_command_real_undo;
	((CommandClass *) klass)->redo = (void (*) (Command*)) editing_tools_adjust_tool_slider_adjustment_command_real_redo;
	((CommandClass *) klass)->compress = (gboolean (*) (Command*, Command*)) editing_tools_adjust_tool_slider_adjustment_command_real_compress;
	G_OBJECT_CLASS (klass)->finalize = editing_tools_adjust_tool_slider_adjustment_command_finalize;
}

static void
editing_tools_adjust_tool_slider_adjustment_command_instance_init (EditingToolsAdjustToolSliderAdjustmentCommand * self,
                                                                   gpointer klass)
{
	self->priv = editing_tools_adjust_tool_slider_adjustment_command_get_instance_private (self);
}

static void
editing_tools_adjust_tool_slider_adjustment_command_finalize (GObject * obj)
{
	EditingToolsAdjustToolSliderAdjustmentCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_ADJUST_TOOL_TYPE_SLIDER_ADJUSTMENT_COMMAND, EditingToolsAdjustToolSliderAdjustmentCommand);
	_pixel_transformation_unref0 (self->priv->new_transformation);
	_pixel_transformation_unref0 (self->priv->old_transformation);
	G_OBJECT_CLASS (editing_tools_adjust_tool_slider_adjustment_command_parent_class)->finalize (obj);
}

static GType
editing_tools_adjust_tool_slider_adjustment_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsAdjustToolSliderAdjustmentCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_adjust_tool_slider_adjustment_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsAdjustToolSliderAdjustmentCommand), 0, (GInstanceInitFunc) editing_tools_adjust_tool_slider_adjustment_command_instance_init, NULL };
	GType editing_tools_adjust_tool_slider_adjustment_command_type_id;
	editing_tools_adjust_tool_slider_adjustment_command_type_id = g_type_register_static (EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, "EditingToolsAdjustToolSliderAdjustmentCommand", &g_define_type_info, 0);
	EditingToolsAdjustToolSliderAdjustmentCommand_private_offset = g_type_add_instance_private (editing_tools_adjust_tool_slider_adjustment_command_type_id, sizeof (EditingToolsAdjustToolSliderAdjustmentCommandPrivate));
	return editing_tools_adjust_tool_slider_adjustment_command_type_id;
}

static GType
editing_tools_adjust_tool_slider_adjustment_command_get_type (void)
{
	static volatile gsize editing_tools_adjust_tool_slider_adjustment_command_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_adjust_tool_slider_adjustment_command_type_id__once)) {
		GType editing_tools_adjust_tool_slider_adjustment_command_type_id;
		editing_tools_adjust_tool_slider_adjustment_command_type_id = editing_tools_adjust_tool_slider_adjustment_command_get_type_once ();
		g_once_init_leave (&editing_tools_adjust_tool_slider_adjustment_command_type_id__once, editing_tools_adjust_tool_slider_adjustment_command_type_id);
	}
	return editing_tools_adjust_tool_slider_adjustment_command_type_id__once;
}

static inline gpointer
editing_tools_adjust_tool_adjust_enhance_command_get_instance_private (EditingToolsAdjustToolAdjustEnhanceCommand* self)
{
	return G_STRUCT_MEMBER_P (self, EditingToolsAdjustToolAdjustEnhanceCommand_private_offset);
}

static EditingToolsAdjustToolAdjustEnhanceCommand*
editing_tools_adjust_tool_adjust_enhance_command_construct (GType object_type,
                                                            EditingToolsAdjustTool* owner,
                                                            Photo* photo)
{
	EditingToolsAdjustToolAdjustEnhanceCommand * self = NULL;
	Photo* _tmp0_;
	PixelTransformationBundle* _tmp1_;
	g_return_val_if_fail (EDITING_TOOLS_IS_ADJUST_TOOL (owner), NULL);
	g_return_val_if_fail (IS_PHOTO (photo), NULL);
	self = (EditingToolsAdjustToolAdjustEnhanceCommand*) editing_tools_adjust_tool_adjust_tool_command_construct (object_type, owner, RESOURCES_ENHANCE_LABEL, RESOURCES_ENHANCE_TOOLTIP);
	_tmp0_ = _g_object_ref0 (photo);
	_g_object_unref0 (self->priv->photo);
	self->priv->photo = _tmp0_;
	_tmp1_ = photo_get_color_adjustments (photo);
	_pixel_transformation_bundle_unref0 (self->priv->original);
	self->priv->original = _tmp1_;
	return self;
}

static EditingToolsAdjustToolAdjustEnhanceCommand*
editing_tools_adjust_tool_adjust_enhance_command_new (EditingToolsAdjustTool* owner,
                                                      Photo* photo)
{
	return editing_tools_adjust_tool_adjust_enhance_command_construct (EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND, owner, photo);
}

static void
editing_tools_adjust_tool_adjust_enhance_command_real_execute (Command* base)
{
	EditingToolsAdjustToolAdjustEnhanceCommand * self;
	PixelTransformationBundle* _tmp0_;
	EditingToolsAdjustTool* _tmp3_;
	PixelTransformationBundle* _tmp4_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND, EditingToolsAdjustToolAdjustEnhanceCommand);
	_tmp0_ = self->priv->enhanced;
	if (_tmp0_ == NULL) {
		Photo* _tmp1_;
		PixelTransformationBundle* _tmp2_;
		_tmp1_ = self->priv->photo;
		_tmp2_ = photo_get_enhance_transformations (_tmp1_);
		_pixel_transformation_bundle_unref0 (self->priv->enhanced);
		self->priv->enhanced = _tmp2_;
	}
	_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp4_ = self->priv->enhanced;
	editing_tools_adjust_tool_set_adjustments (_tmp3_, _tmp4_);
}

static void
editing_tools_adjust_tool_adjust_enhance_command_real_undo (Command* base)
{
	EditingToolsAdjustToolAdjustEnhanceCommand * self;
	EditingToolsAdjustTool* _tmp0_;
	PixelTransformationBundle* _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND, EditingToolsAdjustToolAdjustEnhanceCommand);
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp1_ = self->priv->original;
	editing_tools_adjust_tool_set_adjustments (_tmp0_, _tmp1_);
}

static gboolean
editing_tools_adjust_tool_adjust_enhance_command_real_compress (Command* base,
                                                                Command* command)
{
	EditingToolsAdjustToolAdjustEnhanceCommand * self;
	EnhanceSingleCommand* enhance_single = NULL;
	EnhanceSingleCommand* _tmp0_;
	EnhanceSingleCommand* _tmp1_;
	EditingToolsAdjustToolAdjustEnhanceCommand* enhance_command = NULL;
	EditingToolsAdjustToolAdjustEnhanceCommand* _tmp10_;
	EditingToolsAdjustToolAdjustEnhanceCommand* _tmp11_;
	EditingToolsAdjustToolAdjustEnhanceCommand* _tmp12_;
	EditingToolsAdjustTool* _tmp13_;
	EditingToolsAdjustTool* _tmp14_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND, EditingToolsAdjustToolAdjustEnhanceCommand);
	g_return_val_if_fail (IS_COMMAND (command), FALSE);
	_tmp0_ = _g_object_ref0 (IS_ENHANCE_SINGLE_COMMAND (command) ? ((EnhanceSingleCommand*) command) : NULL);
	enhance_single = _tmp0_;
	_tmp1_ = enhance_single;
	if (_tmp1_ != NULL) {
		Photo* photo = NULL;
		EnhanceSingleCommand* _tmp2_;
		DataSource* _tmp3_;
		Photo* _tmp4_;
		EditingToolsAdjustTool* _tmp5_;
		EditingToolsPhotoCanvas* _tmp6_;
		Photo* _tmp7_;
		Photo* _tmp8_;
		gboolean _tmp9_;
		_tmp2_ = enhance_single;
		_tmp3_ = single_data_source_command_get_source (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, TYPE_SINGLE_DATA_SOURCE_COMMAND, SingleDataSourceCommand));
		photo = G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, TYPE_PHOTO, Photo);
		_tmp4_ = photo;
		_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
		_tmp6_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
		_tmp7_ = editing_tools_photo_canvas_get_photo (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = data_source_equals (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, TYPE_DATA_SOURCE, DataSource), G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, TYPE_DATA_SOURCE, DataSource));
		_g_object_unref0 (_tmp8_);
		result = _tmp9_;
		_g_object_unref0 (photo);
		_g_object_unref0 (enhance_single);
		return result;
	}
	_tmp10_ = _g_object_ref0 (EDITING_TOOLS_ADJUST_TOOL_IS_ADJUST_ENHANCE_COMMAND (command) ? ((EditingToolsAdjustToolAdjustEnhanceCommand*) command) : NULL);
	enhance_command = _tmp10_;
	_tmp11_ = enhance_command;
	if (_tmp11_ == NULL) {
		result = FALSE;
		_g_object_unref0 (enhance_command);
		_g_object_unref0 (enhance_single);
		return result;
	}
	_tmp12_ = enhance_command;
	_tmp13_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	_tmp14_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, EditingToolsAdjustToolAdjustToolCommand)->owner;
	if (_tmp13_ != _tmp14_) {
		result = FALSE;
		_g_object_unref0 (enhance_command);
		_g_object_unref0 (enhance_single);
		return result;
	}
	result = TRUE;
	_g_object_unref0 (enhance_command);
	_g_object_unref0 (enhance_single);
	return result;
}

static void
editing_tools_adjust_tool_adjust_enhance_command_class_init (EditingToolsAdjustToolAdjustEnhanceCommandClass * klass,
                                                             gpointer klass_data)
{
	editing_tools_adjust_tool_adjust_enhance_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &EditingToolsAdjustToolAdjustEnhanceCommand_private_offset);
	((CommandClass *) klass)->execute = (void (*) (Command*)) editing_tools_adjust_tool_adjust_enhance_command_real_execute;
	((CommandClass *) klass)->undo = (void (*) (Command*)) editing_tools_adjust_tool_adjust_enhance_command_real_undo;
	((CommandClass *) klass)->compress = (gboolean (*) (Command*, Command*)) editing_tools_adjust_tool_adjust_enhance_command_real_compress;
	G_OBJECT_CLASS (klass)->finalize = editing_tools_adjust_tool_adjust_enhance_command_finalize;
}

static void
editing_tools_adjust_tool_adjust_enhance_command_instance_init (EditingToolsAdjustToolAdjustEnhanceCommand * self,
                                                                gpointer klass)
{
	self->priv = editing_tools_adjust_tool_adjust_enhance_command_get_instance_private (self);
	self->priv->enhanced = NULL;
}

static void
editing_tools_adjust_tool_adjust_enhance_command_finalize (GObject * obj)
{
	EditingToolsAdjustToolAdjustEnhanceCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_ENHANCE_COMMAND, EditingToolsAdjustToolAdjustEnhanceCommand);
	_g_object_unref0 (self->priv->photo);
	_pixel_transformation_bundle_unref0 (self->priv->original);
	_pixel_transformation_bundle_unref0 (self->priv->enhanced);
	G_OBJECT_CLASS (editing_tools_adjust_tool_adjust_enhance_command_parent_class)->finalize (obj);
}

static GType
editing_tools_adjust_tool_adjust_enhance_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsAdjustToolAdjustEnhanceCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_adjust_tool_adjust_enhance_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsAdjustToolAdjustEnhanceCommand), 0, (GInstanceInitFunc) editing_tools_adjust_tool_adjust_enhance_command_instance_init, NULL };
	GType editing_tools_adjust_tool_adjust_enhance_command_type_id;
	editing_tools_adjust_tool_adjust_enhance_command_type_id = g_type_register_static (EDITING_TOOLS_ADJUST_TOOL_TYPE_ADJUST_TOOL_COMMAND, "EditingToolsAdjustToolAdjustEnhanceCommand", &g_define_type_info, 0);
	EditingToolsAdjustToolAdjustEnhanceCommand_private_offset = g_type_add_instance_private (editing_tools_adjust_tool_adjust_enhance_command_type_id, sizeof (EditingToolsAdjustToolAdjustEnhanceCommandPrivate));
	return editing_tools_adjust_tool_adjust_enhance_command_type_id;
}

static GType
editing_tools_adjust_tool_adjust_enhance_command_get_type (void)
{
	static volatile gsize editing_tools_adjust_tool_adjust_enhance_command_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_adjust_tool_adjust_enhance_command_type_id__once)) {
		GType editing_tools_adjust_tool_adjust_enhance_command_type_id;
		editing_tools_adjust_tool_adjust_enhance_command_type_id = editing_tools_adjust_tool_adjust_enhance_command_get_type_once ();
		g_once_init_leave (&editing_tools_adjust_tool_adjust_enhance_command_type_id__once, editing_tools_adjust_tool_adjust_enhance_command_type_id);
	}
	return editing_tools_adjust_tool_adjust_enhance_command_type_id__once;
}

static void
editing_tools_adjust_tool_class_init (EditingToolsAdjustToolClass * klass,
                                      gpointer klass_data)
{
	editing_tools_adjust_tool_parent_class = g_type_class_peek_parent (klass);
	((EditingToolsEditingToolClass *) klass)->finalize = editing_tools_adjust_tool_finalize;
	g_type_class_adjust_private_offset (klass, &EditingToolsAdjustTool_private_offset);
	((EditingToolsEditingToolClass *) klass)->activate = (void (*) (EditingToolsEditingTool*, EditingToolsPhotoCanvas*)) editing_tools_adjust_tool_real_activate;
	((EditingToolsEditingToolClass *) klass)->get_tool_window = (EditingToolsEditingToolWindow* (*) (EditingToolsEditingTool*)) editing_tools_adjust_tool_real_get_tool_window;
	((EditingToolsEditingToolClass *) klass)->deactivate = (void (*) (EditingToolsEditingTool*)) editing_tools_adjust_tool_real_deactivate;
	((EditingToolsEditingToolClass *) klass)->paint = (void (*) (EditingToolsEditingTool*, cairo_t*)) editing_tools_adjust_tool_real_paint;
	((EditingToolsEditingToolClass *) klass)->get_display_pixbuf = (GdkPixbuf* (*) (EditingToolsEditingTool*, Scaling*, Photo*, Dimensions*, GError**)) editing_tools_adjust_tool_real_get_display_pixbuf;
	((EditingToolsEditingToolClass *) klass)->on_keypress = (gboolean (*) (EditingToolsEditingTool*, GdkEventKey*)) editing_tools_adjust_tool_real_on_keypress;
}

static void
editing_tools_adjust_tool_instance_init (EditingToolsAdjustTool * self,
                                         gpointer klass)
{
	self->priv = editing_tools_adjust_tool_get_instance_private (self);
	self->priv->adjust_tool_window = NULL;
	self->priv->suppress_effect_redraw = FALSE;
	self->priv->draw_to_pixbuf = NULL;
	self->priv->histogram_pixbuf = NULL;
	self->priv->virgin_histogram_pixbuf = NULL;
	self->priv->transformer = NULL;
	self->priv->histogram_transformer = NULL;
	self->priv->transformations = NULL;
	self->priv->fp_pixel_cache = NULL;
	self->priv->fp_pixel_cache_length1 = 0;
	self->priv->_fp_pixel_cache_size_ = self->priv->fp_pixel_cache_length1;
	self->priv->disable_histogram_refresh = FALSE;
	self->priv->temperature_scheduler = NULL;
	self->priv->tint_scheduler = NULL;
	self->priv->contrast_scheduler = NULL;
	self->priv->saturation_scheduler = NULL;
	self->priv->exposure_scheduler = NULL;
	self->priv->shadows_scheduler = NULL;
	self->priv->highlights_scheduler = NULL;
}

static void
editing_tools_adjust_tool_finalize (EditingToolsEditingTool * obj)
{
	EditingToolsAdjustTool * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_TOOLS_TYPE_ADJUST_TOOL, EditingToolsAdjustTool);
	_g_object_unref0 (self->priv->adjust_tool_window);
	_g_object_unref0 (self->priv->draw_to_pixbuf);
	_g_object_unref0 (self->priv->histogram_pixbuf);
	_g_object_unref0 (self->priv->virgin_histogram_pixbuf);
	_pixel_transformer_unref0 (self->priv->transformer);
	_pixel_transformer_unref0 (self->priv->histogram_transformer);
	_pixel_transformation_bundle_unref0 (self->priv->transformations);
	self->priv->fp_pixel_cache = (g_free (self->priv->fp_pixel_cache), NULL);
	_one_shot_scheduler_unref0 (self->priv->temperature_scheduler);
	_one_shot_scheduler_unref0 (self->priv->tint_scheduler);
	_one_shot_scheduler_unref0 (self->priv->contrast_scheduler);
	_one_shot_scheduler_unref0 (self->priv->saturation_scheduler);
	_one_shot_scheduler_unref0 (self->priv->exposure_scheduler);
	_one_shot_scheduler_unref0 (self->priv->shadows_scheduler);
	_one_shot_scheduler_unref0 (self->priv->highlights_scheduler);
	EDITING_TOOLS_EDITING_TOOL_CLASS (editing_tools_adjust_tool_parent_class)->finalize (obj);
}

static GType
editing_tools_adjust_tool_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingToolsAdjustToolClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_tools_adjust_tool_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingToolsAdjustTool), 0, (GInstanceInitFunc) editing_tools_adjust_tool_instance_init, NULL };
	GType editing_tools_adjust_tool_type_id;
	editing_tools_adjust_tool_type_id = g_type_register_static (EDITING_TOOLS_TYPE_EDITING_TOOL, "EditingToolsAdjustTool", &g_define_type_info, 0);
	EditingToolsAdjustTool_private_offset = g_type_add_instance_private (editing_tools_adjust_tool_type_id, sizeof (EditingToolsAdjustToolPrivate));
	return editing_tools_adjust_tool_type_id;
}

GType
editing_tools_adjust_tool_get_type (void)
{
	static volatile gsize editing_tools_adjust_tool_type_id__once = 0;
	if (g_once_init_enter (&editing_tools_adjust_tool_type_id__once)) {
		GType editing_tools_adjust_tool_type_id;
		editing_tools_adjust_tool_type_id = editing_tools_adjust_tool_get_type_once ();
		g_once_init_leave (&editing_tools_adjust_tool_type_id__once, editing_tools_adjust_tool_type_id);
	}
	return editing_tools_adjust_tool_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

