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

/* Copyright 2018 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.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
#include <cairo-gobject.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <gio/gio.h>
#include <float.h>
#include <math.h>
#include <glib/gi18n-lib.h>
#include <pango/pango.h>

#define FACES_TOOL_CONTROL_SPACING 8
#define FACES_TOOL_FACE_LABEL_MAX_CHARS 15
#define FACES_TOOL_FACE_DETECT_MAX_WIDTH 1200
#define FACE_RECTANGLE_NULL_SIZE 0
#define RESOURCES_EDIT_LABEL _ ("_Edit")
#define RESOURCES_DELETE_LABEL _ ("_Delete")
#define RESOURCES_OK_LABEL _ ("_OK")
#define RESOURCES_CANCEL_LABEL _ ("_Cancel")
#define FACE_RECTANGLE_SHAPE_TYPE "Rectangle"
#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 TYPE_FACE_SHAPE_ERROR (face_shape_error_get_type ())

#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_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;

#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;

#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_DIMENSIONS (dimensions_get_type ())
typedef struct _Dimensions Dimensions;

#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_FACES_TOOL (faces_tool_get_type ())
#define FACES_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACES_TOOL, FacesTool))
#define FACES_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACES_TOOL, FacesToolClass))
#define IS_FACES_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACES_TOOL))
#define IS_FACES_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACES_TOOL))
#define FACES_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACES_TOOL, FacesToolClass))

typedef struct _FacesTool FacesTool;
typedef struct _FacesToolClass FacesToolClass;
typedef struct _FacesToolPrivate FacesToolPrivate;

#define TYPE_FACE_SHAPE (face_shape_get_type ())
#define FACE_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE_SHAPE, FaceShape))
#define FACE_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACE_SHAPE, FaceShapeClass))
#define IS_FACE_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE_SHAPE))
#define IS_FACE_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACE_SHAPE))
#define FACE_SHAPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACE_SHAPE, FaceShapeClass))

typedef struct _FaceShape FaceShape;
typedef struct _FaceShapeClass FaceShapeClass;

#define TYPE_BACKGROUND_JOB (background_job_get_type ())
#define BACKGROUND_JOB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BACKGROUND_JOB, BackgroundJob))
#define BACKGROUND_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BACKGROUND_JOB, BackgroundJobClass))
#define IS_BACKGROUND_JOB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BACKGROUND_JOB))
#define IS_BACKGROUND_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BACKGROUND_JOB))
#define BACKGROUND_JOB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BACKGROUND_JOB, BackgroundJobClass))

typedef struct _BackgroundJob BackgroundJob;
typedef struct _BackgroundJobClass BackgroundJobClass;

#define FACES_TOOL_TYPE_FACE_DETECTION_JOB (faces_tool_face_detection_job_get_type ())
#define FACES_TOOL_FACE_DETECTION_JOB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FACES_TOOL_TYPE_FACE_DETECTION_JOB, FacesToolFaceDetectionJob))
#define FACES_TOOL_FACE_DETECTION_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FACES_TOOL_TYPE_FACE_DETECTION_JOB, FacesToolFaceDetectionJobClass))
#define FACES_TOOL_IS_FACE_DETECTION_JOB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FACES_TOOL_TYPE_FACE_DETECTION_JOB))
#define FACES_TOOL_IS_FACE_DETECTION_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FACES_TOOL_TYPE_FACE_DETECTION_JOB))
#define FACES_TOOL_FACE_DETECTION_JOB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FACES_TOOL_TYPE_FACE_DETECTION_JOB, FacesToolFaceDetectionJobClass))

typedef struct _FacesToolFaceDetectionJob FacesToolFaceDetectionJob;
typedef struct _FacesToolFaceDetectionJobClass FacesToolFaceDetectionJobClass;

#define TYPE_WORKERS (workers_get_type ())
#define WORKERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WORKERS, Workers))
#define WORKERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WORKERS, WorkersClass))
#define IS_WORKERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WORKERS))
#define IS_WORKERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WORKERS))
#define WORKERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WORKERS, WorkersClass))

typedef struct _Workers Workers;
typedef struct _WorkersClass WorkersClass;

#define FACES_TOOL_TYPE_FACES_TOOL_WINDOW (faces_tool_faces_tool_window_get_type ())
#define FACES_TOOL_FACES_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FACES_TOOL_TYPE_FACES_TOOL_WINDOW, FacesToolFacesToolWindow))
#define FACES_TOOL_FACES_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FACES_TOOL_TYPE_FACES_TOOL_WINDOW, FacesToolFacesToolWindowClass))
#define FACES_TOOL_IS_FACES_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FACES_TOOL_TYPE_FACES_TOOL_WINDOW))
#define FACES_TOOL_IS_FACES_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FACES_TOOL_TYPE_FACES_TOOL_WINDOW))
#define FACES_TOOL_FACES_TOOL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FACES_TOOL_TYPE_FACES_TOOL_WINDOW, FacesToolFacesToolWindowClass))

typedef struct _FacesToolFacesToolWindow FacesToolFacesToolWindow;
typedef struct _FacesToolFacesToolWindowClass FacesToolFacesToolWindowClass;
typedef enum  {
	FACES_TOOL_EDITING_PHASE_CLICK_TO_EDIT,
	FACES_TOOL_EDITING_PHASE_NOT_EDITING,
	FACES_TOOL_EDITING_PHASE_CREATING_DRAGGING,
	FACES_TOOL_EDITING_PHASE_CREATING_EDITING,
	FACES_TOOL_EDITING_PHASE_EDITING,
	FACES_TOOL_EDITING_PHASE_DETECTING_FACES,
	FACES_TOOL_EDITING_PHASE_DETECTING_FACES_FINISHED
} FacesToolEditingPhase;

#define FACES_TOOL_TYPE_EDITING_PHASE (faces_tool_editing_phase_get_type ())
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _background_job_unref0(var) ((var == NULL) ? NULL : (var = (background_job_unref (var), NULL)))
#define _workers_unref0(var) ((var == NULL) ? NULL : (var = (workers_unref (var), NULL)))

#define TYPE_FACE_ID (face_id_get_type ())
typedef struct _FaceID FaceID;

#define TYPE_FACE_LOCATION (face_location_get_type ())
#define FACE_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE_LOCATION, FaceLocation))
#define FACE_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACE_LOCATION, FaceLocationClass))
#define IS_FACE_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE_LOCATION))
#define IS_FACE_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACE_LOCATION))
#define FACE_LOCATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACE_LOCATION, FaceLocationClass))

typedef struct _FaceLocation FaceLocation;
typedef struct _FaceLocationClass FaceLocationClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define TYPE_FACE (face_get_type ())
#define FACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE, Face))
#define FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACE, FaceClass))
#define IS_FACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE))
#define IS_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACE))
#define FACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACE, FaceClass))

typedef struct _Face Face;
typedef struct _FaceClass FaceClass;

#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 TYPE_SOURCE_COLLECTION (source_collection_get_type ())
#define SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SOURCE_COLLECTION, SourceCollection))
#define SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SOURCE_COLLECTION, SourceCollectionClass))
#define IS_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SOURCE_COLLECTION))
#define IS_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SOURCE_COLLECTION))
#define SOURCE_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SOURCE_COLLECTION, SourceCollectionClass))

typedef struct _SourceCollection SourceCollection;
typedef struct _SourceCollectionClass SourceCollectionClass;

#define TYPE_DATABASE_SOURCE_COLLECTION (database_source_collection_get_type ())
#define DATABASE_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATABASE_SOURCE_COLLECTION, DatabaseSourceCollection))
#define DATABASE_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATABASE_SOURCE_COLLECTION, DatabaseSourceCollectionClass))
#define IS_DATABASE_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATABASE_SOURCE_COLLECTION))
#define IS_DATABASE_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATABASE_SOURCE_COLLECTION))
#define DATABASE_SOURCE_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATABASE_SOURCE_COLLECTION, DatabaseSourceCollectionClass))

typedef struct _DatabaseSourceCollection DatabaseSourceCollection;
typedef struct _DatabaseSourceCollectionClass DatabaseSourceCollectionClass;

#define TYPE_CONTAINER_SOURCE_COLLECTION (container_source_collection_get_type ())
#define CONTAINER_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONTAINER_SOURCE_COLLECTION, ContainerSourceCollection))
#define CONTAINER_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONTAINER_SOURCE_COLLECTION, ContainerSourceCollectionClass))
#define IS_CONTAINER_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONTAINER_SOURCE_COLLECTION))
#define IS_CONTAINER_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONTAINER_SOURCE_COLLECTION))
#define CONTAINER_SOURCE_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONTAINER_SOURCE_COLLECTION, ContainerSourceCollectionClass))

typedef struct _ContainerSourceCollection ContainerSourceCollection;
typedef struct _ContainerSourceCollectionClass ContainerSourceCollectionClass;

#define TYPE_FACE_SOURCE_COLLECTION (face_source_collection_get_type ())
#define FACE_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE_SOURCE_COLLECTION, FaceSourceCollection))
#define FACE_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACE_SOURCE_COLLECTION, FaceSourceCollectionClass))
#define IS_FACE_SOURCE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE_SOURCE_COLLECTION))
#define IS_FACE_SOURCE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACE_SOURCE_COLLECTION))
#define FACE_SOURCE_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACE_SOURCE_COLLECTION, FaceSourceCollectionClass))

typedef struct _FaceSourceCollection FaceSourceCollection;
typedef struct _FaceSourceCollectionClass FaceSourceCollectionClass;
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 ())
typedef void (*CompletionCallback) (BackgroundJob* job, gpointer user_data);
typedef void (*CancellationCallback) (BackgroundJob* job, gpointer user_data);
typedef struct _EditingToolsEditingToolWindowPrivate EditingToolsEditingToolWindowPrivate;
typedef struct _FacesToolFacesToolWindowPrivate FacesToolFacesToolWindowPrivate;
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))

#define FACES_TOOL_TYPE_FACE_WIDGET (faces_tool_face_widget_get_type ())
#define FACES_TOOL_FACE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FACES_TOOL_TYPE_FACE_WIDGET, FacesToolFaceWidget))
#define FACES_TOOL_FACE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FACES_TOOL_TYPE_FACE_WIDGET, FacesToolFaceWidgetClass))
#define FACES_TOOL_IS_FACE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FACES_TOOL_TYPE_FACE_WIDGET))
#define FACES_TOOL_IS_FACE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FACES_TOOL_TYPE_FACE_WIDGET))
#define FACES_TOOL_FACE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FACES_TOOL_TYPE_FACE_WIDGET, FacesToolFaceWidgetClass))

typedef struct _FacesToolFaceWidget FacesToolFaceWidget;
typedef struct _FacesToolFaceWidgetClass FacesToolFaceWidgetClass;

#define TYPE_FACE_RECTANGLE (face_rectangle_get_type ())
#define FACE_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE_RECTANGLE, FaceRectangle))
#define FACE_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACE_RECTANGLE, FaceRectangleClass))
#define IS_FACE_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE_RECTANGLE))
#define IS_FACE_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACE_RECTANGLE))
#define FACE_RECTANGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACE_RECTANGLE, FaceRectangleClass))

typedef struct _FaceRectangle FaceRectangle;
typedef struct _FaceRectangleClass FaceRectangleClass;

#define TYPE_FACE_LOCATION_DATA (face_location_data_get_type ())
typedef struct _FaceLocationData FaceLocationData;

#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;

#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_MODIFY_FACES_COMMAND (modify_faces_command_get_type ())
#define MODIFY_FACES_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MODIFY_FACES_COMMAND, ModifyFacesCommand))
#define MODIFY_FACES_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MODIFY_FACES_COMMAND, ModifyFacesCommandClass))
#define IS_MODIFY_FACES_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MODIFY_FACES_COMMAND))
#define IS_MODIFY_FACES_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MODIFY_FACES_COMMAND))
#define MODIFY_FACES_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MODIFY_FACES_COMMAND, ModifyFacesCommandClass))

typedef struct _ModifyFacesCommand ModifyFacesCommand;
typedef struct _ModifyFacesCommandClass ModifyFacesCommandClass;
typedef struct _FacesToolFaceWidgetPrivate FacesToolFaceWidgetPrivate;

#define TYPE_FACE_LOCATION_ROW (face_location_row_get_type ())
#define FACE_LOCATION_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE_LOCATION_ROW, FaceLocationRow))
#define FACE_LOCATION_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACE_LOCATION_ROW, FaceLocationRowClass))
#define IS_FACE_LOCATION_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE_LOCATION_ROW))
#define IS_FACE_LOCATION_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACE_LOCATION_ROW))
#define FACE_LOCATION_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACE_LOCATION_ROW, FaceLocationRowClass))

typedef struct _FaceLocationRow FaceLocationRow;
typedef struct _FaceLocationRowClass FaceLocationRowClass;

#define TYPE_FACE_ROW (face_row_get_type ())
#define FACE_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE_ROW, FaceRow))
#define FACE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACE_ROW, FaceRowClass))
#define IS_FACE_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE_ROW))
#define IS_FACE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACE_ROW))
#define FACE_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACE_ROW, FaceRowClass))

typedef struct _FaceRow FaceRow;
typedef struct _FaceRowClass FaceRowClass;

#define TYPE_DATABASE_TABLE (database_table_get_type ())
#define DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATABASE_TABLE, DatabaseTable))
#define DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATABASE_TABLE, DatabaseTableClass))
#define IS_DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATABASE_TABLE))
#define IS_DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATABASE_TABLE))
#define DATABASE_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATABASE_TABLE, DatabaseTableClass))

typedef struct _DatabaseTable DatabaseTable;
typedef struct _DatabaseTableClass DatabaseTableClass;

#define TYPE_FACE_TABLE (face_table_get_type ())
#define FACE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE_TABLE, FaceTable))
#define FACE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACE_TABLE, FaceTableClass))
#define IS_FACE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE_TABLE))
#define IS_FACE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACE_TABLE))
#define FACE_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACE_TABLE, FaceTableClass))

typedef struct _FaceTable FaceTable;
typedef struct _FaceTableClass FaceTableClass;

#define TYPE_DATABASE_ERROR (database_error_get_type ())
#define _database_table_unref0(var) ((var == NULL) ? NULL : (var = (database_table_unref (var), NULL)))

#define TYPE_FACE_LOCATION_TABLE (face_location_table_get_type ())
#define FACE_LOCATION_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE_LOCATION_TABLE, FaceLocationTable))
#define FACE_LOCATION_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FACE_LOCATION_TABLE, FaceLocationTableClass))
#define IS_FACE_LOCATION_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE_LOCATION_TABLE))
#define IS_FACE_LOCATION_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FACE_LOCATION_TABLE))
#define FACE_LOCATION_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FACE_LOCATION_TABLE, FaceLocationTableClass))

typedef struct _FaceLocationTable FaceLocationTable;
typedef struct _FaceLocationTableClass FaceLocationTableClass;
typedef struct _FaceLocationRowPrivate FaceLocationRowPrivate;

#define TYPE_FACE_LOCATION_ID (face_location_id_get_type ())
typedef struct _FaceLocationID FaceLocationID;

#define TYPE_PHOTO_ID (photo_id_get_type ())
typedef struct _PhotoID PhotoID;
#define _face_id_free0(var) ((var == NULL) ? NULL : (var = (face_id_free (var), NULL)))
#define _face_location_row_unref0(var) ((var == NULL) ? NULL : (var = (face_location_row_unref (var), NULL)))
typedef struct _BackgroundJobPrivate BackgroundJobPrivate;
typedef enum  {
	BACKGROUND_JOB_JOB_PRIORITY_HIGHEST = 100,
	BACKGROUND_JOB_JOB_PRIORITY_HIGH = 75,
	BACKGROUND_JOB_JOB_PRIORITY_NORMAL = 50,
	BACKGROUND_JOB_JOB_PRIORITY_LOW = 25,
	BACKGROUND_JOB_JOB_PRIORITY_LOWEST = 0
} BackgroundJobJobPriority;

#define BACKGROUND_JOB_TYPE_JOB_PRIORITY (background_job_job_priority_get_type ())
typedef struct _FacesToolFaceDetectionJobPrivate FacesToolFaceDetectionJobPrivate;
enum  {
	FACES_TOOL_FACE_WIDGET_0_PROPERTY,
	FACES_TOOL_FACE_WIDGET_NUM_PROPERTIES
};
static GParamSpec* faces_tool_face_widget_properties[FACES_TOOL_FACE_WIDGET_NUM_PROPERTIES];
#define _pango_attr_list_unref0(var) ((var == NULL) ? NULL : (var = (pango_attr_list_unref (var), NULL)))
enum  {
	FACES_TOOL_FACE_WIDGET_FACE_HIDDEN_SIGNAL,
	FACES_TOOL_FACE_WIDGET_NUM_SIGNALS
};
static guint faces_tool_face_widget_signals[FACES_TOOL_FACE_WIDGET_NUM_SIGNALS] = {0};
enum  {
	FACES_TOOL_FACES_TOOL_WINDOW_0_PROPERTY,
	FACES_TOOL_FACES_TOOL_WINDOW_NUM_PROPERTIES
};
static GParamSpec* faces_tool_faces_tool_window_properties[FACES_TOOL_FACES_TOOL_WINDOW_NUM_PROPERTIES];
enum  {
	FACES_TOOL_FACES_TOOL_WINDOW_FACE_HIDDEN_SIGNAL,
	FACES_TOOL_FACES_TOOL_WINDOW_FACE_EDIT_REQUESTED_SIGNAL,
	FACES_TOOL_FACES_TOOL_WINDOW_FACE_DELETE_REQUESTED_SIGNAL,
	FACES_TOOL_FACES_TOOL_WINDOW_DETECTION_CANCELED_SIGNAL,
	FACES_TOOL_FACES_TOOL_WINDOW_NUM_SIGNALS
};
static guint faces_tool_faces_tool_window_signals[FACES_TOOL_FACES_TOOL_WINDOW_NUM_SIGNALS] = {0};

#define FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW (faces_tool_editing_face_tool_window_get_type ())
#define FACES_TOOL_EDITING_FACE_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW, FacesToolEditingFaceToolWindow))
#define FACES_TOOL_EDITING_FACE_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW, FacesToolEditingFaceToolWindowClass))
#define FACES_TOOL_IS_EDITING_FACE_TOOL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW))
#define FACES_TOOL_IS_EDITING_FACE_TOOL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW))
#define FACES_TOOL_EDITING_FACE_TOOL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW, FacesToolEditingFaceToolWindowClass))

typedef struct _FacesToolEditingFaceToolWindow FacesToolEditingFaceToolWindow;
typedef struct _FacesToolEditingFaceToolWindowClass FacesToolEditingFaceToolWindowClass;
typedef struct _FacesToolEditingFaceToolWindowPrivate FacesToolEditingFaceToolWindowPrivate;
enum  {
	FACES_TOOL_EDITING_FACE_TOOL_WINDOW_0_PROPERTY,
	FACES_TOOL_EDITING_FACE_TOOL_WINDOW_NUM_PROPERTIES
};
static GParamSpec* faces_tool_editing_face_tool_window_properties[FACES_TOOL_EDITING_FACE_TOOL_WINDOW_NUM_PROPERTIES];
enum  {
	FACES_TOOL_EDITING_FACE_TOOL_WINDOW_KEY_PRESSED_SIGNAL,
	FACES_TOOL_EDITING_FACE_TOOL_WINDOW_NUM_SIGNALS
};
static guint faces_tool_editing_face_tool_window_signals[FACES_TOOL_EDITING_FACE_TOOL_WINDOW_NUM_SIGNALS] = {0};

#define TYPE_ABSTRACT_SEMAPHORE (abstract_semaphore_get_type ())
#define ABSTRACT_SEMAPHORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ABSTRACT_SEMAPHORE, AbstractSemaphore))
#define ABSTRACT_SEMAPHORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ABSTRACT_SEMAPHORE, AbstractSemaphoreClass))
#define IS_ABSTRACT_SEMAPHORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ABSTRACT_SEMAPHORE))
#define IS_ABSTRACT_SEMAPHORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ABSTRACT_SEMAPHORE))
#define ABSTRACT_SEMAPHORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ABSTRACT_SEMAPHORE, AbstractSemaphoreClass))

typedef struct _AbstractSemaphore AbstractSemaphore;
typedef struct _AbstractSemaphoreClass AbstractSemaphoreClass;

#define TYPE_FACE_RECT (face_rect_get_type ())
typedef struct _FaceRect FaceRect;

#define TYPE_FACE_DETECT_INTERFACE (face_detect_interface_get_type ())
#define FACE_DETECT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FACE_DETECT_INTERFACE, FaceDetectInterface))
#define IS_FACE_DETECT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FACE_DETECT_INTERFACE))
#define FACE_DETECT_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_FACE_DETECT_INTERFACE, FaceDetectInterfaceIface))

typedef struct _FaceDetectInterface FaceDetectInterface;
typedef struct _FaceDetectInterfaceIface FaceDetectInterfaceIface;

#define TYPE_FACE_DETECT_INTERFACE_PROXY (face_detect_interface_proxy_get_type ())
#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);

typedef enum  {
	FACE_SHAPE_ERROR_CANT_CREATE
} FaceShapeError;
#define FACE_SHAPE_ERROR face_shape_error_quark ()

struct _Dimensions {
	gint width;
	gint height;
};

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

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 _FacesTool {
	EditingToolsEditingTool parent_instance;
	FacesToolPrivate * priv;
};

struct _FacesToolClass {
	EditingToolsEditingToolClass parent_class;
};

struct _FacesToolPrivate {
	cairo_surface_t* image_surface;
	GeeHashMap* face_shapes;
	GeeHashMap* original_face_locations;
	GCancellable* face_detection_cancellable;
	FacesToolFaceDetectionJob* face_detection;
	Workers* workers;
	FaceShape* editing_face_shape;
	FacesToolFacesToolWindow* faces_tool_window;
};

struct _FaceID {
	gint64 id;
};

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

struct _EditingToolsEditingToolWindowClass {
	GtkWindowClass parent_class;
};

struct _FacesToolFacesToolWindow {
	EditingToolsEditingToolWindow parent_instance;
	FacesToolFacesToolWindowPrivate * priv;
	GtkButton* detection_button;
	GtkButton* ok_button;
	GtkButton* cancel_button;
	GtkButton* cancel_detection_button;
};

struct _FacesToolFacesToolWindowClass {
	EditingToolsEditingToolWindowClass parent_class;
};

struct _FaceLocationData {
	gchar* geometry;
	gchar* vec;
};

struct _FacesToolFaceWidget {
	GtkBox parent_instance;
	FacesToolFaceWidgetPrivate * priv;
	GtkButton* edit_button;
	GtkButton* delete_button;
	GtkLabel* label;
	FaceShape* face_shape;
};

struct _FacesToolFaceWidgetClass {
	GtkBoxClass parent_class;
};

typedef enum  {
	DATABASE_ERROR_ERROR,
	DATABASE_ERROR_BACKING,
	DATABASE_ERROR_MEMORY,
	DATABASE_ERROR_ABORT,
	DATABASE_ERROR_LIMITS,
	DATABASE_ERROR_TYPESPEC
} DatabaseError;
#define DATABASE_ERROR database_error_quark ()

struct _FaceLocationID {
	gint64 id;
};

struct _PhotoID {
	gint64 id;
};

struct _FaceLocationRow {
	GTypeInstance parent_instance;
	volatile int ref_count;
	FaceLocationRowPrivate * priv;
	FaceLocationID face_location_id;
	FaceID face_id;
	PhotoID photo_id;
	gchar* geometry;
	gchar* vec;
};

struct _FaceLocationRowClass {
	GTypeClass parent_class;
	void (*finalize) (FaceLocationRow *self);
};

struct _BackgroundJob {
	GTypeInstance parent_instance;
	volatile int ref_count;
	BackgroundJobPrivate * priv;
};

struct _BackgroundJobClass {
	GTypeClass parent_class;
	void (*finalize) (BackgroundJob *self);
	void (*execute) (BackgroundJob* self);
	BackgroundJobJobPriority (*get_priority) (BackgroundJob* self);
};

struct _FacesToolFaceDetectionJob {
	BackgroundJob parent_instance;
	FacesToolFaceDetectionJobPrivate * priv;
	gchar* spawnError;
};

struct _FacesToolFaceDetectionJobClass {
	BackgroundJobClass parent_class;
};

struct _FacesToolFacesToolWindowPrivate {
	FacesToolEditingPhase editing_phase;
	GtkBox* help_layout;
	GtkBox* response_layout;
	GtkSeparator* buttons_text_separator;
	GtkLabel* help_text;
	GtkBox* face_widgets_layout;
	GtkBox* layout;
};

struct _FacesToolEditingFaceToolWindow {
	EditingToolsEditingToolWindow parent_instance;
	FacesToolEditingFaceToolWindowPrivate * priv;
	GtkEntry* entry;
};

struct _FacesToolEditingFaceToolWindowClass {
	EditingToolsEditingToolWindowClass parent_class;
};

struct _FacesToolEditingFaceToolWindowPrivate {
	GtkBox* layout;
};

struct _FacesToolFaceDetectionJobPrivate {
	GeeQueue* faces;
	gchar* image_path;
	gfloat scale;
};

struct _FaceRect {
	gdouble x;
	gdouble y;
	gdouble width;
	gdouble height;
	gdouble* vec;
	gint vec_length1;
};

struct _FaceDetectInterfaceIface {
	GTypeInterface parent_iface;
	FaceRect* (*detect_faces) (FaceDetectInterface* self, const gchar* inputName, const gchar* cascadeName, gdouble scale, gboolean infer, gint* result_length1, GError** error);
	gboolean (*load_net) (FaceDetectInterface* self, const gchar* netFile, GError** error);
	void (*terminate) (FaceDetectInterface* self, GError** error);
};

static gint FacesTool_private_offset;
static gpointer faces_tool_parent_class = NULL;
VALA_EXTERN FaceSourceCollection* face_global;
static gpointer faces_tool_face_widget_parent_class = NULL;
static PangoAttrList* faces_tool_face_widget_attrs_bold;
static PangoAttrList* faces_tool_face_widget_attrs_bold = NULL;
static PangoAttrList* faces_tool_face_widget_attrs_normal;
static PangoAttrList* faces_tool_face_widget_attrs_normal = NULL;
static gint FacesToolFacesToolWindow_private_offset;
static gpointer faces_tool_faces_tool_window_parent_class = NULL;
static gint FacesToolEditingFaceToolWindow_private_offset;
static gpointer faces_tool_editing_face_tool_window_parent_class = NULL;
static gint FacesToolFaceDetectionJob_private_offset;
static gpointer faces_tool_face_detection_job_parent_class = NULL;
VALA_EXTERN gboolean face_detect_connected;
VALA_EXTERN FaceDetectInterface* face_detect_face_detect_proxy;

VALA_EXTERN GQuark face_shape_error_quark (void);
VALA_EXTERN GType face_shape_error_get_type (void) G_GNUC_CONST ;
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 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 editing_tools_editing_tool_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EditingToolsEditingToolWindow, g_object_unref)
VALA_EXTERN GType scaling_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType scale_constraint_get_type (void) G_GNUC_CONST ;
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 Scaling* scaling_dup (const Scaling* self);
VALA_EXTERN void scaling_free (Scaling* self);
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 faces_tool_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FacesTool, editing_tools_editing_tool_unref)
VALA_EXTERN GType face_shape_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FaceShape, g_object_unref)
VALA_EXTERN gpointer background_job_ref (gpointer instance);
VALA_EXTERN void background_job_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_background_job (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_background_job (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_background_job (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_background_job (const GValue* value);
VALA_EXTERN GType background_job_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BackgroundJob, background_job_unref)
static GType faces_tool_face_detection_job_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FacesToolFaceDetectionJob, background_job_unref)
VALA_EXTERN gpointer workers_ref (gpointer instance);
VALA_EXTERN void workers_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_workers (const gchar* name,
                                const gchar* nick,
                                const gchar* blurb,
                                GType object_type,
                                GParamFlags flags);
VALA_EXTERN void value_set_workers (GValue* value,
                        gpointer v_object);
VALA_EXTERN void value_take_workers (GValue* value,
                         gpointer v_object);
VALA_EXTERN gpointer value_get_workers (const GValue* value);
VALA_EXTERN GType workers_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Workers, workers_unref)
static GType faces_tool_faces_tool_window_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FacesToolFacesToolWindow, g_object_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 gboolean editing_tools_editing_tool_on_keypress (EditingToolsEditingTool* self,
                                                 GdkEventKey* event);
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 EditingToolsEditingToolWindow* editing_tools_editing_tool_get_tool_window (EditingToolsEditingTool* self);
VALA_EXTERN void editing_tools_editing_tool_paint (EditingToolsEditingTool* self,
                                       cairo_t* ctx);
static GType faces_tool_editing_phase_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static FacesTool* faces_tool_new (void);
static FacesTool* faces_tool_construct (GType object_type);
VALA_EXTERN EditingToolsEditingTool* editing_tools_editing_tool_construct (GType object_type,
                                                               const gchar* name);
VALA_EXTERN FacesTool* faces_tool_factory (void);
static void faces_tool_real_activate (EditingToolsEditingTool* base,
                               EditingToolsPhotoCanvas* canvas);
static void faces_tool_bind_canvas_handlers (FacesTool* self,
                                      EditingToolsPhotoCanvas* canvas);
VALA_EXTERN void editing_tools_photo_canvas_get_scaled_pixbuf_position (EditingToolsPhotoCanvas* self,
                                                            GdkRectangle* result);
VALA_EXTERN GtkWindow* editing_tools_photo_canvas_get_container (EditingToolsPhotoCanvas* self);
static FacesToolFacesToolWindow* faces_tool_faces_tool_window_new (GtkWindow* container);
static FacesToolFacesToolWindow* faces_tool_faces_tool_window_construct (GType object_type,
                                                                  GtkWindow* container);
VALA_EXTERN GType face_id_get_type (void) G_GNUC_CONST ;
VALA_EXTERN FaceID* face_id_dup (const FaceID* self);
VALA_EXTERN void face_id_free (FaceID* self);
VALA_EXTERN GType face_location_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FaceLocation, g_object_unref)
VALA_EXTERN GeeMap* face_location_get_locations_by_photo (Photo* photo);
VALA_EXTERN Photo* editing_tools_photo_canvas_get_photo (EditingToolsPhotoCanvas* self);
VALA_EXTERN gchar* face_location_get_serialized_geometry (FaceLocation* self);
VALA_EXTERN gchar* face_location_get_serialized_vec (FaceLocation* self);
VALA_EXTERN FaceShape* face_shape_from_serialized (EditingToolsPhotoCanvas* canvas,
                                       const gchar* serialized,
                                       GError** error);
VALA_EXTERN GType face_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Face, g_object_unref)
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 GType source_collection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SourceCollection, data_collection_unref)
VALA_EXTERN GType database_source_collection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DatabaseSourceCollection, data_collection_unref)
VALA_EXTERN GType container_source_collection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ContainerSourceCollection, data_collection_unref)
VALA_EXTERN GType face_source_collection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FaceSourceCollection, data_collection_unref)
VALA_EXTERN Face* face_source_collection_fetch (FaceSourceCollection* self,
                                    FaceID* face_id);
VALA_EXTERN gchar* data_object_get_name (DataObject* self);
VALA_EXTERN void face_shape_set_name (FaceShape* self,
                          const gchar* face_name);
static void faces_tool_add_face (FacesTool* self,
                          FaceShape* face_shape);
static void faces_tool_set_ok_button_sensitivity (FacesTool* self);
VALA_EXTERN Workers* workers_new (guint max_threads,
                      gboolean exclusive);
VALA_EXTERN Workers* workers_construct (GType object_type,
                            guint max_threads,
                            gboolean exclusive);
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 GFile* media_source_get_file (MediaSource* self);
static void faces_tool_on_faces_detected (FacesTool* self);
static void _faces_tool_on_faces_detected_completion_callback (BackgroundJob* job,
                                                        gpointer self);
static void faces_tool_on_detection_cancelled (FacesTool* self,
                                        BackgroundJob* job);
static void _faces_tool_on_detection_cancelled_cancellation_callback (BackgroundJob* job,
                                                               gpointer self);
static FacesToolFaceDetectionJob* faces_tool_face_detection_job_new (FacesToolFacesToolWindow* owner,
                                                              const gchar* image_path,
                                                              gfloat scale,
                                                              CompletionCallback completion_callback,
                                                              gpointer completion_callback_target,
                                                              GCancellable* cancellable,
                                                              CancellationCallback cancellation_callback,
                                                              gpointer cancellation_callback_target);
static FacesToolFaceDetectionJob* faces_tool_face_detection_job_construct (GType object_type,
                                                                    FacesToolFacesToolWindow* owner,
                                                                    const gchar* image_path,
                                                                    gfloat scale,
                                                                    CompletionCallback completion_callback,
                                                                    gpointer completion_callback_target,
                                                                    GCancellable* cancellable,
                                                                    CancellationCallback cancellation_callback,
                                                                    gpointer cancellation_callback_target);
static void faces_tool_bind_window_handlers (FacesTool* self);
static void faces_tool_real_deactivate (EditingToolsEditingTool* base);
static void faces_tool_unbind_canvas_handlers (FacesTool* self,
                                        EditingToolsPhotoCanvas* canvas);
static void faces_tool_unbind_window_handlers (FacesTool* self);
static void faces_tool_prepare_ctx (FacesTool* self,
                             cairo_t* ctx,
                             Dimensions* dim);
static void _faces_tool_prepare_ctx_editing_tools_photo_canvas_new_surface (EditingToolsPhotoCanvas* _sender,
                                                                     cairo_t* ctx,
                                                                     Dimensions* dim,
                                                                     gpointer self);
static void faces_tool_on_resized_pixbuf (FacesTool* self,
                                   Dimensions* old_dim,
                                   GdkPixbuf* scaled,
                                   GdkRectangle* scaled_position);
static void _faces_tool_on_resized_pixbuf_editing_tools_photo_canvas_resized_scaled_pixbuf (EditingToolsPhotoCanvas* _sender,
                                                                                     Dimensions* old_dim,
                                                                                     GdkPixbuf* scaled,
                                                                                     GdkRectangle* scaled_position,
                                                                                     gpointer self);
static gboolean _editing_tools_editing_tool_on_keypress_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                             GdkEventKey* event,
                                                                             gpointer self);
static void faces_tool_on_faces_ok (FacesTool* self);
static void _faces_tool_on_faces_ok_gtk_button_clicked (GtkButton* _sender,
                                                 gpointer self);
VALA_EXTERN void editing_tools_editing_tool_notify_cancel (EditingToolsEditingTool* self);
static void _editing_tools_editing_tool_notify_cancel_gtk_button_clicked (GtkButton* _sender,
                                                                   gpointer self);
static void faces_tool_detect_faces (FacesTool* self);
static void _faces_tool_detect_faces_gtk_button_clicked (GtkButton* _sender,
                                                  gpointer self);
static void faces_tool_on_face_hidden (FacesTool* self);
static void _faces_tool_on_face_hidden_faces_tool_faces_tool_window_face_hidden (FacesToolFacesToolWindow* _sender,
                                                                          gpointer self);
static void faces_tool_edit_face (FacesTool* self,
                           const gchar* face_name);
static void _faces_tool_edit_face_faces_tool_faces_tool_window_face_edit_requested (FacesToolFacesToolWindow* _sender,
                                                                             const gchar* face_name,
                                                                             gpointer self);
static void faces_tool_delete_face (FacesTool* self,
                             const gchar* face_name);
static void _faces_tool_delete_face_faces_tool_faces_tool_window_face_delete_requested (FacesToolFacesToolWindow* _sender,
                                                                                 const gchar* face_name,
                                                                                 gpointer self);
static void faces_tool_cancel_face_detection (FacesTool* self);
static void _faces_tool_cancel_face_detection_faces_tool_faces_tool_window_detection_canceled (FacesToolFacesToolWindow* _sender,
                                                                                        gpointer self);
VALA_EXTERN void face_shape_prepare_ctx (FaceShape* self,
                             cairo_t* ctx,
                             Dimensions* dim);
VALA_EXTERN void face_shape_on_resized_pixbuf (FaceShape* self,
                                   Dimensions* old_dim,
                                   GdkPixbuf* scaled);
static gboolean faces_tool_real_on_keypress (EditingToolsEditingTool* base,
                                      GdkEventKey* event);
static void faces_tool_real_on_left_click (EditingToolsEditingTool* base,
                                    gint x,
                                    gint y);
VALA_EXTERN gdouble application_get_scale (void);
VALA_EXTERN gboolean face_shape_on_left_click (FaceShape* self,
                                   gint x,
                                   gint y);
VALA_EXTERN gboolean face_shape_is_visible (FaceShape* self);
VALA_EXTERN gboolean face_shape_cursor_is_over (FaceShape* self,
                                    gint x,
                                    gint y);
static void faces_tool_edit_face_shape (FacesTool* self,
                                 FaceShape* face_shape,
                                 gboolean creating);
VALA_EXTERN void face_shape_set_editable (FaceShape* self,
                              gboolean editable);
static void faces_tool_new_face_shape (FacesTool* self,
                                gint x,
                                gint y);
static void faces_tool_real_on_left_released (EditingToolsEditingTool* base,
                                       gint x,
                                       gint y);
VALA_EXTERN void face_shape_on_left_released (FaceShape* self,
                                  gint x,
                                  gint y);
static FacesToolEditingPhase faces_tool_faces_tool_window_get_editing_phase (FacesToolFacesToolWindow* self);
static void faces_tool_faces_tool_window_set_editing_phase (FacesToolFacesToolWindow* self,
                                                     FacesToolEditingPhase phase,
                                                     FaceShape* face_shape);
static void faces_tool_real_on_motion (EditingToolsEditingTool* base,
                                gint x,
                                gint y,
                                GdkModifierType mask);
VALA_EXTERN void face_shape_hide (FaceShape* self);
VALA_EXTERN GType faces_tool_face_widget_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FacesToolFaceWidget, g_object_unref)
VALA_EXTERN FacesToolFaceWidget* face_shape_get_widget (FaceShape* self);
VALA_EXTERN void faces_tool_face_widget_deactivate_label (FacesToolFaceWidget* self);
VALA_EXTERN gdouble face_shape_get_distance (FaceShape* self,
                                 gint x,
                                 gint y);
VALA_EXTERN void face_shape_show (FaceShape* self);
VALA_EXTERN void faces_tool_face_widget_activate_label (FacesToolFaceWidget* self);
VALA_EXTERN void face_shape_on_motion (FaceShape* self,
                           gint x,
                           gint y,
                           GdkModifierType mask);
static gboolean faces_tool_real_on_leave_notify_event (EditingToolsEditingTool* base);
VALA_EXTERN gboolean is_pointer_over (GdkWindow* window);
VALA_EXTERN GdkWindow* editing_tools_photo_canvas_get_drawing_window (EditingToolsPhotoCanvas* self);
VALA_EXTERN gboolean face_shape_is_editable (FaceShape* self);
static EditingToolsEditingToolWindow* faces_tool_real_get_tool_window (EditingToolsEditingTool* base);
static void faces_tool_real_paint (EditingToolsEditingTool* base,
                            cairo_t* default_ctx);
VALA_EXTERN void editing_tools_photo_canvas_paint_surface (EditingToolsPhotoCanvas* self,
                                               cairo_surface_t* surface,
                                               gboolean over);
VALA_EXTERN FaceRectangle* face_rectangle_new (EditingToolsPhotoCanvas* canvas,
                                   gint x,
                                   gint y,
                                   gint half_width,
                                   gint half_height,
                                   gdouble* vec,
                                   gint vec_length1);
VALA_EXTERN FaceRectangle* face_rectangle_construct (GType object_type,
                                         EditingToolsPhotoCanvas* canvas,
                                         gint x,
                                         gint y,
                                         gint half_width,
                                         gint half_height,
                                         gdouble* vec,
                                         gint vec_length1);
VALA_EXTERN GType face_rectangle_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FaceRectangle, g_object_unref)
static void faces_tool_hide_visible_face (FacesTool* self);
static void _faces_tool_add_face_face_shape_add_me_requested (FaceShape* _sender,
                                                       FaceShape* face_shape,
                                                       gpointer self);
static void faces_tool_release_face_shape (FacesTool* self);
static void _faces_tool_release_face_shape_face_shape_delete_me_requested (FaceShape* _sender,
                                                                    gpointer self);
VALA_EXTERN GType face_location_data_get_type (void) G_GNUC_CONST ;
VALA_EXTERN FaceLocationData* face_location_data_dup (const FaceLocationData* self);
VALA_EXTERN void face_location_data_free (FaceLocationData* self);
VALA_EXTERN void face_location_data_copy (const FaceLocationData* self,
                              FaceLocationData* dest);
VALA_EXTERN void face_location_data_destroy (FaceLocationData* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (FaceLocationData, face_location_data_destroy)
VALA_EXTERN gboolean face_shape_get_known (FaceShape* self);
VALA_EXTERN Face* face_for_name (const gchar* name);
VALA_EXTERN gchar* face_shape_get_name (FaceShape* self);
VALA_EXTERN gchar* face_shape_serialize (FaceShape* self,
                             gboolean geometry_only);
VALA_EXTERN GType command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Command, g_object_unref)
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 modify_faces_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModifyFacesCommand, g_object_unref)
VALA_EXTERN ModifyFacesCommand* modify_faces_command_new (MediaSource* media,
                                              GeeMap* new_face_list);
VALA_EXTERN ModifyFacesCommand* modify_faces_command_construct (GType object_type,
                                                    MediaSource* media,
                                                    GeeMap* new_face_list);
VALA_EXTERN gchar* face_prep_face_name (const gchar* name);
VALA_EXTERN void face_shape_set_known (FaceShape* self,
                           gboolean known);
static void faces_tool_faces_tool_window_add_face (FacesToolFacesToolWindow* self,
                                            FaceShape* face_shape);
static void faces_tool_faces_tool_window_ok_button_set_sensitive (FacesToolFacesToolWindow* self,
                                                           gboolean sensitive);
VALA_EXTERN void workers_enqueue (Workers* self,
                      BackgroundJob* job);
static void faces_tool_pick_faces_from_autodetected (FacesTool* self);
static gchar* faces_tool_face_detection_job_get_next (FacesToolFaceDetectionJob* self);
VALA_EXTERN gboolean face_shape_equals (FaceShape* self,
                            FaceShape* face_shape);
static Face* faces_tool_get_face_match (FacesTool* self,
                                 FaceShape* face_shape,
                                 gdouble threshold);
VALA_EXTERN gdouble face_shape_get_guess (FaceShape* self);
static gdouble faces_tool_dot_product (FacesTool* self,
                                gdouble* vec1,
                                gint vec1_length1,
                                gdouble* vec2,
                                gint vec2_length1);
VALA_EXTERN gpointer face_location_row_ref (gpointer instance);
VALA_EXTERN void face_location_row_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_face_location_row (const gchar* name,
                                          const gchar* nick,
                                          const gchar* blurb,
                                          GType object_type,
                                          GParamFlags flags);
VALA_EXTERN void value_set_face_location_row (GValue* value,
                                  gpointer v_object);
VALA_EXTERN void value_take_face_location_row (GValue* value,
                                   gpointer v_object);
VALA_EXTERN gpointer value_get_face_location_row (const GValue* value);
VALA_EXTERN GType face_location_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FaceLocationRow, face_location_row_unref)
VALA_EXTERN gpointer face_row_ref (gpointer instance);
VALA_EXTERN void face_row_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_face_row (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags);
VALA_EXTERN void value_set_face_row (GValue* value,
                         gpointer v_object);
VALA_EXTERN void value_take_face_row (GValue* value,
                          gpointer v_object);
VALA_EXTERN gpointer value_get_face_row (const GValue* value);
VALA_EXTERN GType face_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FaceRow, face_row_unref)
VALA_EXTERN gpointer database_table_ref (gpointer instance);
VALA_EXTERN void database_table_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_database_table (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_database_table (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_database_table (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_database_table (const GValue* value);
VALA_EXTERN GType database_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DatabaseTable, database_table_unref)
VALA_EXTERN GType face_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FaceTable, database_table_unref)
VALA_EXTERN FaceTable* face_table_get_instance (void);
VALA_EXTERN GQuark database_error_quark (void);
VALA_EXTERN GType database_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GeeList* face_table_get_ref_rows (FaceTable* self,
                                  GError** error);
VALA_EXTERN GType face_location_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FaceLocationTable, database_table_unref)
VALA_EXTERN FaceLocationTable* face_location_table_get_instance (void);
VALA_EXTERN GeeList* face_location_table_get_face_ref_vecs (FaceLocationTable* self,
                                                GeeList* face_rows,
                                                GError** error);
VALA_EXTERN GType face_location_id_get_type (void) G_GNUC_CONST ;
VALA_EXTERN FaceLocationID* face_location_id_dup (const FaceLocationID* self);
VALA_EXTERN void face_location_id_free (FaceLocationID* self);
VALA_EXTERN GType photo_id_get_type (void) G_GNUC_CONST ;
VALA_EXTERN PhotoID* photo_id_dup (const PhotoID* self);
VALA_EXTERN void photo_id_free (PhotoID* self);
static void _vala_array_add135 (gdouble* * array,
                         gint* length,
                         gint* size,
                         gdouble value);
VALA_EXTERN gdouble* face_shape_get_face_vec (FaceShape* self,
                                  gint* result_length1);
VALA_EXTERN void face_shape_set_guess (FaceShape* self,
                           gdouble guess);
VALA_EXTERN GType background_job_job_priority_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void app_window_error_message (const gchar* message,
                               GtkWindow* parent);
static void faces_tool_face_detection_job_reset (FacesToolFaceDetectionJob* self);
VALA_EXTERN void background_job_cancel (BackgroundJob* self);
VALA_EXTERN FacesToolFaceWidget* faces_tool_face_widget_new (FaceShape* face_shape);
VALA_EXTERN FacesToolFaceWidget* faces_tool_face_widget_construct (GType object_type,
                                                       FaceShape* face_shape);
VALA_EXTERN void face_shape_set_widget (FaceShape* self,
                            FacesToolFaceWidget* face_widget);
VALA_EXTERN gboolean faces_tool_face_widget_on_enter_notify_event (FacesToolFaceWidget* self);
VALA_EXTERN gboolean faces_tool_face_widget_on_leave_notify_event (FacesToolFaceWidget* self);
static void faces_tool_face_widget_finalize (GObject * obj);
static GType faces_tool_face_widget_get_type_once (void);
VALA_EXTERN EditingToolsEditingToolWindow* editing_tools_editing_tool_window_construct (GType object_type,
                                                                            GtkWindow* container);
static void faces_tool_faces_tool_window_on_cancel_detection (FacesToolFacesToolWindow* self);
static void _faces_tool_faces_tool_window_on_cancel_detection_gtk_button_clicked (GtkButton* _sender,
                                                                           gpointer self);
static void faces_tool_faces_tool_window_on_face_hidden (FacesToolFacesToolWindow* self);
static void _faces_tool_faces_tool_window_on_face_hidden_faces_tool_face_widget_face_hidden (FacesToolFaceWidget* _sender,
                                                                                      gpointer self);
static void faces_tool_faces_tool_window_edit_face (FacesToolFacesToolWindow* self,
                                             GtkButton* button);
static void _faces_tool_faces_tool_window_edit_face_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self);
static void faces_tool_faces_tool_window_delete_face (FacesToolFacesToolWindow* self,
                                               GtkButton* button);
static void _faces_tool_faces_tool_window_delete_face_gtk_button_clicked (GtkButton* _sender,
                                                                   gpointer self);
static gboolean _faces_tool_face_widget_on_enter_notify_event_gtk_widget_enter_notify_event (GtkWidget* _sender,
                                                                                      GdkEventCrossing* event,
                                                                                      gpointer self);
static gboolean _faces_tool_face_widget_on_leave_notify_event_gtk_widget_leave_notify_event (GtkWidget* _sender,
                                                                                      GdkEventCrossing* event,
                                                                                      gpointer self);
static void faces_tool_faces_tool_window_finalize (GObject * obj);
static GType faces_tool_faces_tool_window_get_type_once (void);
VALA_EXTERN GType faces_tool_editing_face_tool_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FacesToolEditingFaceToolWindow, g_object_unref)
VALA_EXTERN FacesToolEditingFaceToolWindow* faces_tool_editing_face_tool_window_new (GtkWindow* container);
VALA_EXTERN FacesToolEditingFaceToolWindow* faces_tool_editing_face_tool_window_construct (GType object_type,
                                                                               GtkWindow* container);
static gboolean faces_tool_editing_face_tool_window_real_key_press_event (GtkWidget* base,
                                                                   GdkEventKey* event);
static void g_cclosure_user_marshal_BOOLEAN__BOXED (GClosure * closure,
                                             GValue * return_value,
                                             guint n_param_values,
                                             const GValue * param_values,
                                             gpointer invocation_hint,
                                             gpointer marshal_data);
static void faces_tool_editing_face_tool_window_finalize (GObject * obj);
static GType faces_tool_editing_face_tool_window_get_type_once (void);
VALA_EXTERN void background_job_execute (BackgroundJob* self);
VALA_EXTERN gpointer abstract_semaphore_ref (gpointer instance);
VALA_EXTERN void abstract_semaphore_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_abstract_semaphore (const gchar* name,
                                           const gchar* nick,
                                           const gchar* blurb,
                                           GType object_type,
                                           GParamFlags flags);
VALA_EXTERN void value_set_abstract_semaphore (GValue* value,
                                   gpointer v_object);
VALA_EXTERN void value_take_abstract_semaphore (GValue* value,
                                    gpointer v_object);
VALA_EXTERN gpointer value_get_abstract_semaphore (const GValue* value);
VALA_EXTERN GType abstract_semaphore_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AbstractSemaphore, abstract_semaphore_unref)
VALA_EXTERN BackgroundJob* background_job_construct (GType object_type,
                                         GObject* owner,
                                         CompletionCallback callback,
                                         gpointer callback_target,
                                         GCancellable* cancellable,
                                         CancellationCallback cancellation,
                                         gpointer cancellation_target,
                                         AbstractSemaphore* completion_semaphore);
static void faces_tool_face_detection_job_real_execute (BackgroundJob* base);
VALA_EXTERN GType face_rect_get_type (void) G_GNUC_CONST ;
VALA_EXTERN FaceRect* face_rect_dup (const FaceRect* self);
VALA_EXTERN void face_rect_free (FaceRect* self);
VALA_EXTERN void face_rect_copy (const FaceRect* self,
                     FaceRect* dest);
VALA_EXTERN void face_rect_destroy (FaceRect* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (FaceRect, face_rect_destroy)
VALA_EXTERN GType face_detect_interface_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint face_detect_interface_register_object (void* object,
                                             GDBusConnection* connection,
                                             const gchar* path,
                                             GError** error);
VALA_EXTERN GType face_detect_interface_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FaceDetectInterface, g_object_unref)
VALA_EXTERN FaceRect* face_detect_interface_detect_faces (FaceDetectInterface* self,
                                              const gchar* inputName,
                                              const gchar* cascadeName,
                                              gdouble scale,
                                              gboolean infer,
                                              gint* result_length1,
                                              GError** error);
VALA_EXTERN GFile* app_dirs_get_haarcascade_file (void);
static void _vala_FaceRect_array_free (FaceRect * array,
                                gssize array_length);
static void faces_tool_face_detection_job_finalize (BackgroundJob * obj);
static GType faces_tool_face_detection_job_get_type_once (void);
static void faces_tool_finalize (EditingToolsEditingTool * obj);
static GType faces_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);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

GQuark
face_shape_error_quark (void)
{
	return g_quark_from_static_string ("face-shape-error-quark");
}

static GType
face_shape_error_get_type_once (void)
{
	static const GEnumValue values[] = {{FACE_SHAPE_ERROR_CANT_CREATE, "FACE_SHAPE_ERROR_CANT_CREATE", "cant-create"}, {0, NULL, NULL}};
	GType face_shape_error_type_id;
	face_shape_error_type_id = g_enum_register_static ("FaceShapeError", values);
	return face_shape_error_type_id;
}

GType
face_shape_error_get_type (void)
{
	static volatile gsize face_shape_error_type_id__once = 0;
	if (g_once_init_enter (&face_shape_error_type_id__once)) {
		GType face_shape_error_type_id;
		face_shape_error_type_id = face_shape_error_get_type_once ();
		g_once_init_leave (&face_shape_error_type_id__once, face_shape_error_type_id);
	}
	return face_shape_error_type_id__once;
}

static inline gpointer
faces_tool_get_instance_private (FacesTool* self)
{
	return G_STRUCT_MEMBER_P (self, FacesTool_private_offset);
}

static GType
faces_tool_editing_phase_get_type_once (void)
{
	static const GEnumValue values[] = {{FACES_TOOL_EDITING_PHASE_CLICK_TO_EDIT, "FACES_TOOL_EDITING_PHASE_CLICK_TO_EDIT", "click-to-edit"}, {FACES_TOOL_EDITING_PHASE_NOT_EDITING, "FACES_TOOL_EDITING_PHASE_NOT_EDITING", "not-editing"}, {FACES_TOOL_EDITING_PHASE_CREATING_DRAGGING, "FACES_TOOL_EDITING_PHASE_CREATING_DRAGGING", "creating-dragging"}, {FACES_TOOL_EDITING_PHASE_CREATING_EDITING, "FACES_TOOL_EDITING_PHASE_CREATING_EDITING", "creating-editing"}, {FACES_TOOL_EDITING_PHASE_EDITING, "FACES_TOOL_EDITING_PHASE_EDITING", "editing"}, {FACES_TOOL_EDITING_PHASE_DETECTING_FACES, "FACES_TOOL_EDITING_PHASE_DETECTING_FACES", "detecting-faces"}, {FACES_TOOL_EDITING_PHASE_DETECTING_FACES_FINISHED, "FACES_TOOL_EDITING_PHASE_DETECTING_FACES_FINISHED", "detecting-faces-finished"}, {0, NULL, NULL}};
	GType faces_tool_editing_phase_type_id;
	faces_tool_editing_phase_type_id = g_enum_register_static ("FacesToolEditingPhase", values);
	return faces_tool_editing_phase_type_id;
}

static GType
faces_tool_editing_phase_get_type (void)
{
	static volatile gsize faces_tool_editing_phase_type_id__once = 0;
	if (g_once_init_enter (&faces_tool_editing_phase_type_id__once)) {
		GType faces_tool_editing_phase_type_id;
		faces_tool_editing_phase_type_id = faces_tool_editing_phase_get_type_once ();
		g_once_init_leave (&faces_tool_editing_phase_type_id__once, faces_tool_editing_phase_type_id);
	}
	return faces_tool_editing_phase_type_id__once;
}

static FacesTool*
faces_tool_construct (GType object_type)
{
	FacesTool* self = NULL;
	self = (FacesTool*) editing_tools_editing_tool_construct (object_type, "FacesTool");
	return self;
}

static FacesTool*
faces_tool_new (void)
{
	return faces_tool_construct (TYPE_FACES_TOOL);
}

FacesTool*
faces_tool_factory (void)
{
	FacesTool* _tmp0_;
	FacesTool* result;
	_tmp0_ = faces_tool_new ();
	result = _tmp0_;
	return result;
}

static void
_faces_tool_on_faces_detected_completion_callback (BackgroundJob* job,
                                                   gpointer self)
{
	faces_tool_on_faces_detected ((FacesTool*) self);
}

static void
_faces_tool_on_detection_cancelled_cancellation_callback (BackgroundJob* job,
                                                          gpointer self)
{
	faces_tool_on_detection_cancelled ((FacesTool*) self, job);
}

static void
faces_tool_real_activate (EditingToolsEditingTool* base,
                          EditingToolsPhotoCanvas* canvas)
{
	FacesTool * self;
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	cairo_surface_t* _tmp2_;
	GdkRectangle scaled_pixbuf_position = {0};
	GdkRectangle _tmp3_ = {0};
	GdkRectangle _tmp4_;
	GdkRectangle _tmp5_;
	cairo_surface_t* _tmp6_;
	GtkWindow* _tmp7_;
	GtkWindow* _tmp8_;
	FacesToolFacesToolWindow* _tmp9_;
	GeeMap* face_locations = NULL;
	Photo* _tmp10_;
	Photo* _tmp11_;
	GeeMap* _tmp12_;
	GeeMap* _tmp13_;
	GeeMap* _tmp14_;
	GCancellable* _tmp58_;
	Workers* _tmp59_;
	Dimensions dimensions = {0};
	Photo* _tmp60_;
	Photo* _tmp61_;
	Dimensions _tmp62_ = {0};
	Dimensions _tmp63_;
	gfloat scale_factor = 0.0F;
	Dimensions _tmp64_;
	FacesToolFacesToolWindow* _tmp65_;
	Photo* _tmp66_;
	Photo* _tmp67_;
	GFile* _tmp68_;
	GFile* _tmp69_;
	gchar* _tmp70_;
	gchar* _tmp71_;
	GCancellable* _tmp72_;
	FacesToolFaceDetectionJob* _tmp73_;
	GError* _inner_error0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FACES_TOOL, FacesTool);
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, TYPE_FACE_SHAPE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->face_shapes);
	self->priv->face_shapes = _tmp0_;
	_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->original_face_locations);
	self->priv->original_face_locations = _tmp1_;
	faces_tool_bind_canvas_handlers (self, canvas);
	_tmp2_ = self->priv->image_surface;
	if (_tmp2_ != NULL) {
		_cairo_surface_destroy0 (self->priv->image_surface);
		self->priv->image_surface = NULL;
	}
	editing_tools_photo_canvas_get_scaled_pixbuf_position (canvas, &_tmp3_);
	scaled_pixbuf_position = _tmp3_;
	_tmp4_ = scaled_pixbuf_position;
	_tmp5_ = scaled_pixbuf_position;
	_tmp6_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, _tmp4_.width, _tmp5_.height);
	_cairo_surface_destroy0 (self->priv->image_surface);
	self->priv->image_surface = _tmp6_;
	_tmp7_ = editing_tools_photo_canvas_get_container (canvas);
	_tmp8_ = _tmp7_;
	_tmp9_ = faces_tool_faces_tool_window_new (_tmp8_);
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->faces_tool_window);
	self->priv->faces_tool_window = _tmp9_;
	_g_object_unref0 (_tmp8_);
	_tmp10_ = editing_tools_photo_canvas_get_photo (canvas);
	_tmp11_ = _tmp10_;
	_tmp12_ = face_location_get_locations_by_photo (_tmp11_);
	_tmp13_ = _tmp12_;
	_g_object_unref0 (_tmp11_);
	face_locations = _tmp13_;
	_tmp14_ = face_locations;
	if (_tmp14_ != NULL) {
		{
			GeeIterator* _entry_it = NULL;
			GeeMap* _tmp15_;
			GeeSet* _tmp16_;
			GeeSet* _tmp17_;
			GeeSet* _tmp18_;
			GeeIterator* _tmp19_;
			GeeIterator* _tmp20_;
			_tmp15_ = face_locations;
			_tmp16_ = gee_map_get_entries (_tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = _tmp17_;
			_tmp19_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, GEE_TYPE_ITERABLE, GeeIterable));
			_tmp20_ = _tmp19_;
			_g_object_unref0 (_tmp18_);
			_entry_it = _tmp20_;
			while (TRUE) {
				GeeIterator* _tmp21_;
				GeeMapEntry* entry = NULL;
				GeeIterator* _tmp22_;
				gpointer _tmp23_;
				FaceShape* new_face_shape = NULL;
				gchar* serialized_geometry = NULL;
				GeeMapEntry* _tmp24_;
				gconstpointer _tmp25_;
				gconstpointer _tmp26_;
				gchar* _tmp27_;
				gchar* serialized_vec = NULL;
				GeeMapEntry* _tmp28_;
				gconstpointer _tmp29_;
				gconstpointer _tmp30_;
				gchar* _tmp31_;
				gchar* face_shape_str = NULL;
				const gchar* _tmp32_;
				gchar* _tmp33_;
				gchar* _tmp34_;
				const gchar* _tmp35_;
				gchar* _tmp36_;
				gchar* _tmp37_;
				Face* face = NULL;
				FaceSourceCollection* _tmp43_;
				GeeMapEntry* _tmp44_;
				gconstpointer _tmp45_;
				gconstpointer _tmp46_;
				FaceID _tmp47_;
				Face* _tmp48_;
				Face* _tmp49_;
				gchar* face_name = NULL;
				Face* _tmp50_;
				gchar* _tmp51_;
				FaceShape* _tmp52_;
				const gchar* _tmp53_;
				FaceShape* _tmp54_;
				GeeHashMap* _tmp55_;
				const gchar* _tmp56_;
				const gchar* _tmp57_;
				_tmp21_ = _entry_it;
				if (!gee_iterator_next (_tmp21_)) {
					break;
				}
				_tmp22_ = _entry_it;
				_tmp23_ = gee_iterator_get (_tmp22_);
				entry = (GeeMapEntry*) _tmp23_;
				_tmp24_ = entry;
				_tmp25_ = gee_map_entry_get_value (_tmp24_);
				_tmp26_ = _tmp25_;
				_tmp27_ = face_location_get_serialized_geometry ((FaceLocation*) _tmp26_);
				serialized_geometry = _tmp27_;
				_tmp28_ = entry;
				_tmp29_ = gee_map_entry_get_value (_tmp28_);
				_tmp30_ = _tmp29_;
				_tmp31_ = face_location_get_serialized_vec ((FaceLocation*) _tmp30_);
				serialized_vec = _tmp31_;
				_tmp32_ = serialized_geometry;
				_tmp33_ = g_strconcat (_tmp32_, ";", NULL);
				_tmp34_ = _tmp33_;
				_tmp35_ = serialized_vec;
				_tmp36_ = g_strconcat (_tmp34_, _tmp35_, NULL);
				_tmp37_ = _tmp36_;
				_g_free0 (_tmp34_);
				face_shape_str = _tmp37_;
				{
					FaceShape* _tmp38_ = NULL;
					const gchar* _tmp39_;
					FaceShape* _tmp40_;
					FaceShape* _tmp41_;
					_tmp39_ = face_shape_str;
					_tmp40_ = face_shape_from_serialized (canvas, _tmp39_, &_inner_error0_);
					_tmp38_ = _tmp40_;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						if (_inner_error0_->domain == FACE_SHAPE_ERROR) {
							goto __catch0_face_shape_error;
						}
						_g_free0 (face_shape_str);
						_g_free0 (serialized_vec);
						_g_free0 (serialized_geometry);
						_g_object_unref0 (new_face_shape);
						_g_object_unref0 (entry);
						_g_object_unref0 (_entry_it);
						_g_object_unref0 (face_locations);
						g_critical ("file %s: line %d: unexpected 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;
					}
					_tmp41_ = _tmp38_;
					_tmp38_ = NULL;
					_g_object_unref0 (new_face_shape);
					new_face_shape = _tmp41_;
					_g_object_unref0 (_tmp38_);
				}
				goto __finally0;
				__catch0_face_shape_error:
				{
					GError* e = NULL;
					GError* _tmp42_;
					e = _inner_error0_;
					_inner_error0_ = NULL;
					_tmp42_ = e;
					if (g_error_matches (_tmp42_, FACE_SHAPE_ERROR, FACE_SHAPE_ERROR_CANT_CREATE)) {
						_g_error_free0 (e);
						_g_free0 (face_shape_str);
						_g_free0 (serialized_vec);
						_g_free0 (serialized_geometry);
						_g_object_unref0 (new_face_shape);
						_g_object_unref0 (entry);
						continue;
					}
					g_assert_not_reached ();
					_g_error_free0 (e);
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_free0 (face_shape_str);
					_g_free0 (serialized_vec);
					_g_free0 (serialized_geometry);
					_g_object_unref0 (new_face_shape);
					_g_object_unref0 (entry);
					_g_object_unref0 (_entry_it);
					_g_object_unref0 (face_locations);
					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;
				}
				_tmp43_ = face_global;
				_tmp44_ = entry;
				_tmp45_ = gee_map_entry_get_key (_tmp44_);
				_tmp46_ = _tmp45_;
				_tmp47_ = *((FaceID*) _tmp46_);
				_tmp48_ = face_source_collection_fetch (_tmp43_, &_tmp47_);
				face = _tmp48_;
				_tmp49_ = face;
				_vala_assert (_tmp49_ != NULL, "face != null");
				_tmp50_ = face;
				_tmp51_ = data_object_get_name (G_TYPE_CHECK_INSTANCE_CAST (_tmp50_, TYPE_DATA_OBJECT, DataObject));
				face_name = _tmp51_;
				_tmp52_ = new_face_shape;
				_tmp53_ = face_name;
				face_shape_set_name (_tmp52_, _tmp53_);
				_tmp54_ = new_face_shape;
				faces_tool_add_face (self, _tmp54_);
				_tmp55_ = self->priv->original_face_locations;
				_tmp56_ = face_name;
				_tmp57_ = serialized_geometry;
				gee_abstract_map_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp55_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), _tmp56_, _tmp57_);
				_g_free0 (face_name);
				_g_object_unref0 (face);
				_g_free0 (face_shape_str);
				_g_free0 (serialized_vec);
				_g_free0 (serialized_geometry);
				_g_object_unref0 (new_face_shape);
				_g_object_unref0 (entry);
			}
			_g_object_unref0 (_entry_it);
		}
	}
	faces_tool_set_ok_button_sensitivity (self);
	_tmp58_ = g_cancellable_new ();
	_g_object_unref0 (self->priv->face_detection_cancellable);
	self->priv->face_detection_cancellable = _tmp58_;
	_tmp59_ = workers_new ((guint) 1, FALSE);
	_workers_unref0 (self->priv->workers);
	self->priv->workers = _tmp59_;
	_tmp60_ = editing_tools_photo_canvas_get_photo (canvas);
	_tmp61_ = _tmp60_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp61_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_NONE, &_tmp62_);
	_tmp63_ = _tmp62_;
	_g_object_unref0 (_tmp61_);
	dimensions = _tmp63_;
	_tmp64_ = dimensions;
	scale_factor = ((gfloat) _tmp64_.width) / FACES_TOOL_FACE_DETECT_MAX_WIDTH;
	_tmp65_ = self->priv->faces_tool_window;
	_tmp66_ = editing_tools_photo_canvas_get_photo (canvas);
	_tmp67_ = _tmp66_;
	_tmp68_ = media_source_get_file (G_TYPE_CHECK_INSTANCE_CAST (_tmp67_, TYPE_MEDIA_SOURCE, MediaSource));
	_tmp69_ = _tmp68_;
	_tmp70_ = g_file_get_path (_tmp69_);
	_tmp71_ = _tmp70_;
	_tmp72_ = self->priv->face_detection_cancellable;
	_tmp73_ = faces_tool_face_detection_job_new (_tmp65_, _tmp71_, scale_factor, _faces_tool_on_faces_detected_completion_callback, self, _tmp72_, _faces_tool_on_detection_cancelled_cancellation_callback, self);
	_background_job_unref0 (self->priv->face_detection);
	self->priv->face_detection = _tmp73_;
	_g_free0 (_tmp71_);
	_g_object_unref0 (_tmp69_);
	_g_object_unref0 (_tmp67_);
	faces_tool_bind_window_handlers (self);
	EDITING_TOOLS_EDITING_TOOL_CLASS (faces_tool_parent_class)->activate (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), canvas);
	_g_object_unref0 (face_locations);
}

static void
faces_tool_real_deactivate (EditingToolsEditingTool* base)
{
	FacesTool * self;
	EditingToolsPhotoCanvas* _tmp0_;
	FacesToolFacesToolWindow* _tmp2_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FACES_TOOL, FacesTool);
	_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;
		faces_tool_unbind_canvas_handlers (self, _tmp1_);
	}
	_tmp2_ = self->priv->faces_tool_window;
	if (_tmp2_ != NULL) {
		FacesToolFacesToolWindow* _tmp3_;
		FacesToolFacesToolWindow* _tmp4_;
		faces_tool_unbind_window_handlers (self);
		_tmp3_ = self->priv->faces_tool_window;
		gtk_widget_hide (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget));
		_tmp4_ = self->priv->faces_tool_window;
		gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_widget_get_type (), GtkWidget));
		_g_object_unref0 (self->priv->faces_tool_window);
		self->priv->faces_tool_window = NULL;
	}
	EDITING_TOOLS_EDITING_TOOL_CLASS (faces_tool_parent_class)->deactivate (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
}

static void
_faces_tool_prepare_ctx_editing_tools_photo_canvas_new_surface (EditingToolsPhotoCanvas* _sender,
                                                                cairo_t* ctx,
                                                                Dimensions* dim,
                                                                gpointer self)
{
	faces_tool_prepare_ctx ((FacesTool*) self, ctx, dim);
}

static void
_faces_tool_on_resized_pixbuf_editing_tools_photo_canvas_resized_scaled_pixbuf (EditingToolsPhotoCanvas* _sender,
                                                                                Dimensions* old_dim,
                                                                                GdkPixbuf* scaled,
                                                                                GdkRectangle* scaled_position,
                                                                                gpointer self)
{
	faces_tool_on_resized_pixbuf ((FacesTool*) self, old_dim, scaled, scaled_position);
}

static void
faces_tool_bind_canvas_handlers (FacesTool* self,
                                 EditingToolsPhotoCanvas* canvas)
{
	g_return_if_fail (IS_FACES_TOOL (self));
	g_return_if_fail (EDITING_TOOLS_IS_PHOTO_CANVAS (canvas));
	g_signal_connect (canvas, "new-surface", (GCallback) _faces_tool_prepare_ctx_editing_tools_photo_canvas_new_surface, self);
	g_signal_connect (canvas, "resized-scaled-pixbuf", (GCallback) _faces_tool_on_resized_pixbuf_editing_tools_photo_canvas_resized_scaled_pixbuf, self);
}

static void
faces_tool_unbind_canvas_handlers (FacesTool* self,
                                   EditingToolsPhotoCanvas* canvas)
{
	guint _tmp0_;
	guint _tmp1_;
	g_return_if_fail (IS_FACES_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) _faces_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) _faces_tool_on_resized_pixbuf_editing_tools_photo_canvas_resized_scaled_pixbuf, self);
}

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
_faces_tool_on_faces_ok_gtk_button_clicked (GtkButton* _sender,
                                            gpointer self)
{
	faces_tool_on_faces_ok ((FacesTool*) 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
_faces_tool_detect_faces_gtk_button_clicked (GtkButton* _sender,
                                             gpointer self)
{
	faces_tool_detect_faces ((FacesTool*) self);
}

static void
_faces_tool_on_face_hidden_faces_tool_faces_tool_window_face_hidden (FacesToolFacesToolWindow* _sender,
                                                                     gpointer self)
{
	faces_tool_on_face_hidden ((FacesTool*) self);
}

static void
_faces_tool_edit_face_faces_tool_faces_tool_window_face_edit_requested (FacesToolFacesToolWindow* _sender,
                                                                        const gchar* face_name,
                                                                        gpointer self)
{
	faces_tool_edit_face ((FacesTool*) self, face_name);
}

static void
_faces_tool_delete_face_faces_tool_faces_tool_window_face_delete_requested (FacesToolFacesToolWindow* _sender,
                                                                            const gchar* face_name,
                                                                            gpointer self)
{
	faces_tool_delete_face ((FacesTool*) self, face_name);
}

static void
_faces_tool_cancel_face_detection_faces_tool_faces_tool_window_detection_canceled (FacesToolFacesToolWindow* _sender,
                                                                                   gpointer self)
{
	faces_tool_cancel_face_detection ((FacesTool*) self);
}

static void
faces_tool_bind_window_handlers (FacesTool* self)
{
	FacesToolFacesToolWindow* _tmp0_;
	FacesToolFacesToolWindow* _tmp1_;
	GtkButton* _tmp2_;
	FacesToolFacesToolWindow* _tmp3_;
	GtkButton* _tmp4_;
	FacesToolFacesToolWindow* _tmp5_;
	GtkButton* _tmp6_;
	FacesToolFacesToolWindow* _tmp7_;
	FacesToolFacesToolWindow* _tmp8_;
	FacesToolFacesToolWindow* _tmp9_;
	FacesToolFacesToolWindow* _tmp10_;
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = self->priv->faces_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->faces_tool_window;
	_tmp2_ = _tmp1_->ok_button;
	g_signal_connect (_tmp2_, "clicked", (GCallback) _faces_tool_on_faces_ok_gtk_button_clicked, self);
	_tmp3_ = self->priv->faces_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->faces_tool_window;
	_tmp6_ = _tmp5_->detection_button;
	g_signal_connect (_tmp6_, "clicked", (GCallback) _faces_tool_detect_faces_gtk_button_clicked, self);
	_tmp7_ = self->priv->faces_tool_window;
	g_signal_connect (_tmp7_, "face-hidden", (GCallback) _faces_tool_on_face_hidden_faces_tool_faces_tool_window_face_hidden, self);
	_tmp8_ = self->priv->faces_tool_window;
	g_signal_connect (_tmp8_, "face-edit-requested", (GCallback) _faces_tool_edit_face_faces_tool_faces_tool_window_face_edit_requested, self);
	_tmp9_ = self->priv->faces_tool_window;
	g_signal_connect (_tmp9_, "face-delete-requested", (GCallback) _faces_tool_delete_face_faces_tool_faces_tool_window_face_delete_requested, self);
	_tmp10_ = self->priv->faces_tool_window;
	g_signal_connect (_tmp10_, "detection-canceled", (GCallback) _faces_tool_cancel_face_detection_faces_tool_faces_tool_window_detection_canceled, self);
}

static void
faces_tool_unbind_window_handlers (FacesTool* self)
{
	FacesToolFacesToolWindow* _tmp0_;
	guint _tmp1_;
	FacesToolFacesToolWindow* _tmp2_;
	GtkButton* _tmp3_;
	guint _tmp4_;
	FacesToolFacesToolWindow* _tmp5_;
	GtkButton* _tmp6_;
	guint _tmp7_;
	FacesToolFacesToolWindow* _tmp8_;
	GtkButton* _tmp9_;
	guint _tmp10_;
	FacesToolFacesToolWindow* _tmp11_;
	guint _tmp12_;
	FacesToolFacesToolWindow* _tmp13_;
	guint _tmp14_;
	FacesToolFacesToolWindow* _tmp15_;
	guint _tmp16_;
	FacesToolFacesToolWindow* _tmp17_;
	guint _tmp18_;
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = self->priv->faces_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->faces_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) _faces_tool_on_faces_ok_gtk_button_clicked, self);
	_tmp5_ = self->priv->faces_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->faces_tool_window;
	_tmp9_ = _tmp8_->detection_button;
	g_signal_parse_name ("clicked", gtk_button_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) _faces_tool_detect_faces_gtk_button_clicked, self);
	_tmp11_ = self->priv->faces_tool_window;
	g_signal_parse_name ("face-hidden", FACES_TOOL_TYPE_FACES_TOOL_WINDOW, &_tmp12_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp11_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp12_, 0, NULL, (GCallback) _faces_tool_on_face_hidden_faces_tool_faces_tool_window_face_hidden, self);
	_tmp13_ = self->priv->faces_tool_window;
	g_signal_parse_name ("face-edit-requested", FACES_TOOL_TYPE_FACES_TOOL_WINDOW, &_tmp14_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp13_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp14_, 0, NULL, (GCallback) _faces_tool_edit_face_faces_tool_faces_tool_window_face_edit_requested, self);
	_tmp15_ = self->priv->faces_tool_window;
	g_signal_parse_name ("face-delete-requested", FACES_TOOL_TYPE_FACES_TOOL_WINDOW, &_tmp16_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp15_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp16_, 0, NULL, (GCallback) _faces_tool_delete_face_faces_tool_faces_tool_window_face_delete_requested, self);
	_tmp17_ = self->priv->faces_tool_window;
	g_signal_parse_name ("detection-canceled", FACES_TOOL_TYPE_FACES_TOOL_WINDOW, &_tmp18_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp17_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp18_, 0, NULL, (GCallback) _faces_tool_cancel_face_detection_faces_tool_faces_tool_window_detection_canceled, self);
}

static void
faces_tool_prepare_ctx (FacesTool* self,
                        cairo_t* ctx,
                        Dimensions* dim)
{
	FaceShape* _tmp0_;
	g_return_if_fail (IS_FACES_TOOL (self));
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (dim != NULL);
	_tmp0_ = self->priv->editing_face_shape;
	if (_tmp0_ != NULL) {
		FaceShape* _tmp1_;
		Dimensions _tmp2_;
		_tmp1_ = self->priv->editing_face_shape;
		_tmp2_ = *dim;
		face_shape_prepare_ctx (_tmp1_, ctx, &_tmp2_);
	}
}

static void
faces_tool_on_resized_pixbuf (FacesTool* self,
                              Dimensions* old_dim,
                              GdkPixbuf* scaled,
                              GdkRectangle* scaled_position)
{
	cairo_surface_t* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	cairo_surface_t* _tmp5_;
	cairo_t* ctx = NULL;
	cairo_surface_t* _tmp6_;
	cairo_t* _tmp7_;
	cairo_t* _tmp8_;
	cairo_t* _tmp9_;
	FaceShape* _tmp10_;
	GeeHashMap* _tmp13_;
	g_return_if_fail (IS_FACES_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);
	_tmp0_ = self->priv->image_surface;
	if (_tmp0_ != NULL) {
		_cairo_surface_destroy0 (self->priv->image_surface);
		self->priv->image_surface = NULL;
	}
	_tmp1_ = gdk_pixbuf_get_width (scaled);
	_tmp2_ = _tmp1_;
	_tmp3_ = gdk_pixbuf_get_height (scaled);
	_tmp4_ = _tmp3_;
	_tmp5_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, _tmp2_, _tmp4_);
	_cairo_surface_destroy0 (self->priv->image_surface);
	self->priv->image_surface = _tmp5_;
	_tmp6_ = self->priv->image_surface;
	_tmp7_ = cairo_create (_tmp6_);
	ctx = _tmp7_;
	_tmp8_ = ctx;
	cairo_set_source_rgba (_tmp8_, 255.0, 255.0, 255.0, 0.0);
	_tmp9_ = ctx;
	cairo_paint (_tmp9_);
	_tmp10_ = self->priv->editing_face_shape;
	if (_tmp10_ != NULL) {
		FaceShape* _tmp11_;
		Dimensions _tmp12_;
		_tmp11_ = self->priv->editing_face_shape;
		_tmp12_ = *old_dim;
		face_shape_on_resized_pixbuf (_tmp11_, &_tmp12_, scaled);
	}
	_tmp13_ = self->priv->face_shapes;
	if (_tmp13_ != NULL) {
		{
			GeeIterator* _face_shape_it = NULL;
			GeeHashMap* _tmp14_;
			GeeCollection* _tmp15_;
			GeeCollection* _tmp16_;
			GeeCollection* _tmp17_;
			GeeIterator* _tmp18_;
			GeeIterator* _tmp19_;
			_tmp14_ = self->priv->face_shapes;
			_tmp15_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
			_tmp16_ = _tmp15_;
			_tmp17_ = _tmp16_;
			_tmp18_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, GEE_TYPE_ITERABLE, GeeIterable));
			_tmp19_ = _tmp18_;
			_g_object_unref0 (_tmp17_);
			_face_shape_it = _tmp19_;
			while (TRUE) {
				GeeIterator* _tmp20_;
				FaceShape* face_shape = NULL;
				GeeIterator* _tmp21_;
				gpointer _tmp22_;
				FaceShape* _tmp23_;
				Dimensions _tmp24_;
				_tmp20_ = _face_shape_it;
				if (!gee_iterator_next (_tmp20_)) {
					break;
				}
				_tmp21_ = _face_shape_it;
				_tmp22_ = gee_iterator_get (_tmp21_);
				face_shape = (FaceShape*) _tmp22_;
				_tmp23_ = face_shape;
				_tmp24_ = *old_dim;
				face_shape_on_resized_pixbuf (_tmp23_, &_tmp24_, scaled);
				_g_object_unref0 (face_shape);
			}
			_g_object_unref0 (_face_shape_it);
		}
	}
	_cairo_destroy0 (ctx);
}

static gboolean
faces_tool_real_on_keypress (EditingToolsEditingTool* base,
                             GdkEventKey* event)
{
	FacesTool * self;
	gchar* event_keyval = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	const gchar* _tmp3_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FACES_TOOL, FacesTool);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = gdk_keyval_name (event->keyval);
	_tmp1_ = g_strdup (_tmp0_);
	event_keyval = _tmp1_;
	_tmp3_ = event_keyval;
	if (g_strcmp0 (_tmp3_, "Return") == 0) {
		_tmp2_ = TRUE;
	} else {
		const gchar* _tmp4_;
		_tmp4_ = event_keyval;
		_tmp2_ = g_strcmp0 (_tmp4_, "KP_Enter") == 0;
	}
	if (_tmp2_) {
		faces_tool_on_faces_ok (self);
		result = TRUE;
		_g_free0 (event_keyval);
		return result;
	}
	result = EDITING_TOOLS_EDITING_TOOL_CLASS (faces_tool_parent_class)->on_keypress (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), event);
	_g_free0 (event_keyval);
	return result;
}

static void
faces_tool_real_on_left_click (EditingToolsEditingTool* base,
                               gint x,
                               gint y)
{
	FacesTool * self;
	gdouble scale = 0.0;
	gboolean _tmp0_ = FALSE;
	FaceShape* _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FACES_TOOL, FacesTool);
	scale = application_get_scale ();
	x = (gint) lround (x * scale);
	y = (gint) lround (y * scale);
	_tmp1_ = self->priv->editing_face_shape;
	if (_tmp1_ != NULL) {
		FaceShape* _tmp2_;
		_tmp2_ = self->priv->editing_face_shape;
		_tmp0_ = face_shape_on_left_click (_tmp2_, x, y);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	{
		GeeIterator* _face_shape_it = NULL;
		GeeHashMap* _tmp3_;
		GeeCollection* _tmp4_;
		GeeCollection* _tmp5_;
		GeeCollection* _tmp6_;
		GeeIterator* _tmp7_;
		GeeIterator* _tmp8_;
		_tmp3_ = self->priv->face_shapes;
		_tmp4_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_tmp5_ = _tmp4_;
		_tmp6_ = _tmp5_;
		_tmp7_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp8_ = _tmp7_;
		_g_object_unref0 (_tmp6_);
		_face_shape_it = _tmp8_;
		while (TRUE) {
			GeeIterator* _tmp9_;
			FaceShape* face_shape = NULL;
			GeeIterator* _tmp10_;
			gpointer _tmp11_;
			gboolean _tmp12_ = FALSE;
			FaceShape* _tmp13_;
			_tmp9_ = _face_shape_it;
			if (!gee_iterator_next (_tmp9_)) {
				break;
			}
			_tmp10_ = _face_shape_it;
			_tmp11_ = gee_iterator_get (_tmp10_);
			face_shape = (FaceShape*) _tmp11_;
			_tmp13_ = face_shape;
			if (face_shape_is_visible (_tmp13_)) {
				FaceShape* _tmp14_;
				_tmp14_ = face_shape;
				_tmp12_ = face_shape_cursor_is_over (_tmp14_, x, y);
			} else {
				_tmp12_ = FALSE;
			}
			if (_tmp12_) {
				FaceShape* _tmp15_;
				FaceShape* _tmp16_;
				_tmp15_ = face_shape;
				faces_tool_edit_face_shape (self, _tmp15_, FALSE);
				_tmp16_ = face_shape;
				face_shape_set_editable (_tmp16_, TRUE);
				_g_object_unref0 (face_shape);
				_g_object_unref0 (_face_shape_it);
				return;
			}
			_g_object_unref0 (face_shape);
		}
		_g_object_unref0 (_face_shape_it);
	}
	faces_tool_new_face_shape (self, x, y);
}

static void
faces_tool_real_on_left_released (EditingToolsEditingTool* base,
                                  gint x,
                                  gint y)
{
	FacesTool * self;
	gdouble scale = 0.0;
	FaceShape* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FACES_TOOL, FacesTool);
	scale = application_get_scale ();
	x = (gint) lround (x * scale);
	y = (gint) lround (y * scale);
	_tmp0_ = self->priv->editing_face_shape;
	if (_tmp0_ != NULL) {
		FaceShape* _tmp1_;
		FacesToolFacesToolWindow* _tmp2_;
		_tmp1_ = self->priv->editing_face_shape;
		face_shape_on_left_released (_tmp1_, x, y);
		_tmp2_ = self->priv->faces_tool_window;
		if (faces_tool_faces_tool_window_get_editing_phase (_tmp2_) == FACES_TOOL_EDITING_PHASE_CREATING_DRAGGING) {
			FacesToolFacesToolWindow* _tmp3_;
			_tmp3_ = self->priv->faces_tool_window;
			faces_tool_faces_tool_window_set_editing_phase (_tmp3_, FACES_TOOL_EDITING_PHASE_CREATING_EDITING, NULL);
		}
	}
}

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

static void
faces_tool_real_on_motion (EditingToolsEditingTool* base,
                           gint x,
                           gint y,
                           GdkModifierType mask)
{
	FacesTool * self;
	gdouble scale = 0.0;
	FaceShape* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FACES_TOOL, FacesTool);
	scale = application_get_scale ();
	x = (gint) lround (x * scale);
	y = (gint) lround (y * scale);
	_tmp0_ = self->priv->editing_face_shape;
	if (_tmp0_ == NULL) {
		FaceShape* to_show = NULL;
		gdouble distance = 0.0;
		gdouble new_distance = 0.0;
		FaceShape* _tmp28_;
		to_show = NULL;
		distance = (gdouble) 0;
		{
			GeeIterator* _face_shape_it = NULL;
			GeeHashMap* _tmp1_;
			GeeCollection* _tmp2_;
			GeeCollection* _tmp3_;
			GeeCollection* _tmp4_;
			GeeIterator* _tmp5_;
			GeeIterator* _tmp6_;
			_tmp1_ = self->priv->face_shapes;
			_tmp2_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
			_tmp3_ = _tmp2_;
			_tmp4_ = _tmp3_;
			_tmp5_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_ITERABLE, GeeIterable));
			_tmp6_ = _tmp5_;
			_g_object_unref0 (_tmp4_);
			_face_shape_it = _tmp6_;
			while (TRUE) {
				GeeIterator* _tmp7_;
				FaceShape* face_shape = NULL;
				GeeIterator* _tmp8_;
				gpointer _tmp9_;
				gboolean cursor_is_over = FALSE;
				FaceShape* _tmp10_;
				_tmp7_ = _face_shape_it;
				if (!gee_iterator_next (_tmp7_)) {
					break;
				}
				_tmp8_ = _face_shape_it;
				_tmp9_ = gee_iterator_get (_tmp8_);
				face_shape = (FaceShape*) _tmp9_;
				_tmp10_ = face_shape;
				cursor_is_over = face_shape_cursor_is_over (_tmp10_, x, y);
				if (cursor_is_over) {
					FaceShape* _tmp11_;
					FaceShape* _tmp12_;
					FacesToolFaceWidget* _tmp13_;
					FacesToolFaceWidget* _tmp14_;
					FaceShape* _tmp15_;
					_tmp11_ = face_shape;
					face_shape_hide (_tmp11_);
					_tmp12_ = face_shape;
					_tmp13_ = face_shape_get_widget (_tmp12_);
					_tmp14_ = _tmp13_;
					faces_tool_face_widget_deactivate_label (_tmp14_);
					_g_object_unref0 (_tmp14_);
					_tmp15_ = to_show;
					if (_tmp15_ == NULL) {
						FaceShape* _tmp16_;
						FaceShape* _tmp17_;
						FaceShape* _tmp18_;
						_tmp16_ = face_shape;
						_tmp17_ = _g_object_ref0 (_tmp16_);
						_g_object_unref0 (to_show);
						to_show = _tmp17_;
						_tmp18_ = face_shape;
						distance = face_shape_get_distance (_tmp18_, x, y);
					} else {
						FaceShape* _tmp19_;
						_tmp19_ = face_shape;
						new_distance = face_shape_get_distance (_tmp19_, x, y);
						if (new_distance < distance) {
							FaceShape* _tmp20_;
							FaceShape* _tmp21_;
							_tmp20_ = face_shape;
							_tmp21_ = _g_object_ref0 (_tmp20_);
							_g_object_unref0 (to_show);
							to_show = _tmp21_;
							distance = new_distance;
						}
					}
				} else {
					gboolean _tmp22_ = FALSE;
					if (!cursor_is_over) {
						FaceShape* _tmp23_;
						_tmp23_ = face_shape;
						_tmp22_ = face_shape_is_visible (_tmp23_);
					} else {
						_tmp22_ = FALSE;
					}
					if (_tmp22_) {
						FaceShape* _tmp24_;
						FaceShape* _tmp25_;
						FacesToolFaceWidget* _tmp26_;
						FacesToolFaceWidget* _tmp27_;
						_tmp24_ = face_shape;
						face_shape_hide (_tmp24_);
						_tmp25_ = face_shape;
						_tmp26_ = face_shape_get_widget (_tmp25_);
						_tmp27_ = _tmp26_;
						faces_tool_face_widget_deactivate_label (_tmp27_);
						_g_object_unref0 (_tmp27_);
					}
				}
				_g_object_unref0 (face_shape);
			}
			_g_object_unref0 (_face_shape_it);
		}
		_tmp28_ = to_show;
		if (_tmp28_ == NULL) {
			FacesToolFacesToolWindow* _tmp29_;
			_tmp29_ = self->priv->faces_tool_window;
			faces_tool_faces_tool_window_set_editing_phase (_tmp29_, FACES_TOOL_EDITING_PHASE_NOT_EDITING, NULL);
		} else {
			FacesToolFacesToolWindow* _tmp30_;
			FaceShape* _tmp31_;
			FaceShape* _tmp32_;
			FaceShape* _tmp33_;
			FacesToolFaceWidget* _tmp34_;
			FacesToolFaceWidget* _tmp35_;
			_tmp30_ = self->priv->faces_tool_window;
			_tmp31_ = to_show;
			faces_tool_faces_tool_window_set_editing_phase (_tmp30_, FACES_TOOL_EDITING_PHASE_CLICK_TO_EDIT, _tmp31_);
			_tmp32_ = to_show;
			face_shape_show (_tmp32_);
			_tmp33_ = to_show;
			_tmp34_ = face_shape_get_widget (_tmp33_);
			_tmp35_ = _tmp34_;
			faces_tool_face_widget_activate_label (_tmp35_);
			_g_object_unref0 (_tmp35_);
		}
		_g_object_unref0 (to_show);
	} else {
		FaceShape* _tmp36_;
		_tmp36_ = self->priv->editing_face_shape;
		face_shape_on_motion (_tmp36_, x, y, mask);
	}
}

static gboolean
faces_tool_real_on_leave_notify_event (EditingToolsEditingTool* base)
{
	FacesTool * self;
	gboolean _tmp0_ = FALSE;
	EditingToolsPhotoCanvas* _tmp1_;
	GdkWindow* _tmp2_;
	GdkWindow* _tmp3_;
	gboolean _tmp4_;
	FaceShape* _tmp7_;
	FacesToolFacesToolWindow* _tmp23_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FACES_TOOL, FacesTool);
	_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp2_ = editing_tools_photo_canvas_get_drawing_window (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = is_pointer_over (_tmp3_);
	_g_object_unref0 (_tmp3_);
	if (_tmp4_) {
		FacesToolFacesToolWindow* _tmp5_;
		GdkWindow* _tmp6_;
		_tmp5_ = self->priv->faces_tool_window;
		_tmp6_ = gtk_widget_get_window (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_widget_get_type (), GtkWidget));
		_tmp0_ = !is_pointer_over (_tmp6_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp7_ = self->priv->editing_face_shape;
	if (_tmp7_ != NULL) {
		result = EDITING_TOOLS_EDITING_TOOL_CLASS (faces_tool_parent_class)->on_leave_notify_event (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
		return result;
	}
	{
		GeeIterator* _face_shape_it = NULL;
		GeeHashMap* _tmp8_;
		GeeCollection* _tmp9_;
		GeeCollection* _tmp10_;
		GeeCollection* _tmp11_;
		GeeIterator* _tmp12_;
		GeeIterator* _tmp13_;
		_tmp8_ = self->priv->face_shapes;
		_tmp9_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_tmp10_ = _tmp9_;
		_tmp11_ = _tmp10_;
		_tmp12_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp13_ = _tmp12_;
		_g_object_unref0 (_tmp11_);
		_face_shape_it = _tmp13_;
		while (TRUE) {
			GeeIterator* _tmp14_;
			FaceShape* face_shape = NULL;
			GeeIterator* _tmp15_;
			gpointer _tmp16_;
			FaceShape* _tmp17_;
			FaceShape* _tmp18_;
			_tmp14_ = _face_shape_it;
			if (!gee_iterator_next (_tmp14_)) {
				break;
			}
			_tmp15_ = _face_shape_it;
			_tmp16_ = gee_iterator_get (_tmp15_);
			face_shape = (FaceShape*) _tmp16_;
			_tmp17_ = face_shape;
			if (face_shape_is_editable (_tmp17_)) {
				result = EDITING_TOOLS_EDITING_TOOL_CLASS (faces_tool_parent_class)->on_leave_notify_event (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
				_g_object_unref0 (face_shape);
				_g_object_unref0 (_face_shape_it);
				return result;
			}
			_tmp18_ = face_shape;
			if (face_shape_is_visible (_tmp18_)) {
				FaceShape* _tmp19_;
				FaceShape* _tmp20_;
				FacesToolFaceWidget* _tmp21_;
				FacesToolFaceWidget* _tmp22_;
				_tmp19_ = face_shape;
				face_shape_hide (_tmp19_);
				_tmp20_ = face_shape;
				_tmp21_ = face_shape_get_widget (_tmp20_);
				_tmp22_ = _tmp21_;
				faces_tool_face_widget_deactivate_label (_tmp22_);
				_g_object_unref0 (_tmp22_);
				_g_object_unref0 (face_shape);
				break;
			}
			_g_object_unref0 (face_shape);
		}
		_g_object_unref0 (_face_shape_it);
	}
	_tmp23_ = self->priv->faces_tool_window;
	faces_tool_faces_tool_window_set_editing_phase (_tmp23_, FACES_TOOL_EDITING_PHASE_NOT_EDITING, NULL);
	result = EDITING_TOOLS_EDITING_TOOL_CLASS (faces_tool_parent_class)->on_leave_notify_event (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool));
	return result;
}

static EditingToolsEditingToolWindow*
faces_tool_real_get_tool_window (EditingToolsEditingTool* base)
{
	FacesTool * self;
	FacesToolFacesToolWindow* _tmp0_;
	EditingToolsEditingToolWindow* _tmp1_;
	EditingToolsEditingToolWindow* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FACES_TOOL, FacesTool);
	_tmp0_ = self->priv->faces_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
faces_tool_real_paint (EditingToolsEditingTool* base,
                       cairo_t* default_ctx)
{
	FacesTool * self;
	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_;
	cairo_t* _tmp10_;
	cairo_t* _tmp11_;
	cairo_t* _tmp12_;
	EditingToolsPhotoCanvas* _tmp13_;
	cairo_surface_t* _tmp14_;
	FaceShape* _tmp15_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FACES_TOOL, FacesTool);
	g_return_if_fail (default_ctx != NULL);
	_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, (gdouble) w, (gdouble) h);
	cairo_fill (default_ctx);
	cairo_paint (default_ctx);
	_tmp8_ = self->priv->image_surface;
	_tmp9_ = cairo_create (_tmp8_);
	ctx = _tmp9_;
	_tmp10_ = ctx;
	cairo_set_operator (_tmp10_, CAIRO_OPERATOR_SOURCE);
	_tmp11_ = ctx;
	cairo_set_source_rgba (_tmp11_, 0.0, 0.0, 0.0, 0.0);
	_tmp12_ = ctx;
	cairo_paint (_tmp12_);
	_tmp13_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp14_ = self->priv->image_surface;
	editing_tools_photo_canvas_paint_surface (_tmp13_, _tmp14_, TRUE);
	_tmp15_ = self->priv->editing_face_shape;
	if (_tmp15_ != NULL) {
		FaceShape* _tmp16_;
		_tmp16_ = self->priv->editing_face_shape;
		face_shape_show (_tmp16_);
	}
	_cairo_destroy0 (ctx);
}

static void
faces_tool_new_face_shape (FacesTool* self,
                           gint x,
                           gint y)
{
	EditingToolsPhotoCanvas* _tmp0_;
	gdouble* _tmp1_;
	gdouble* _tmp2_;
	gint _tmp2__length1;
	FaceRectangle* _tmp3_;
	FaceRectangle* _tmp4_;
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp1_ = g_new0 (gdouble, 0);
	_tmp2_ = _tmp1_;
	_tmp2__length1 = 0;
	_tmp3_ = face_rectangle_new (_tmp0_, x, y, FACE_RECTANGLE_NULL_SIZE, FACE_RECTANGLE_NULL_SIZE, _tmp2_, 0);
	_tmp4_ = _tmp3_;
	faces_tool_edit_face_shape (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, TYPE_FACE_SHAPE, FaceShape), TRUE);
	_g_object_unref0 (_tmp4_);
	_tmp2_ = (g_free (_tmp2_), NULL);
}

static void
_faces_tool_add_face_face_shape_add_me_requested (FaceShape* _sender,
                                                  FaceShape* face_shape,
                                                  gpointer self)
{
	faces_tool_add_face ((FacesTool*) self, face_shape);
}

static void
_faces_tool_release_face_shape_face_shape_delete_me_requested (FaceShape* _sender,
                                                               gpointer self)
{
	faces_tool_release_face_shape ((FacesTool*) self);
}

static void
faces_tool_edit_face_shape (FacesTool* self,
                            FaceShape* face_shape,
                            gboolean creating)
{
	FaceShape* _tmp0_;
	FaceShape* _tmp11_;
	FaceShape* _tmp12_;
	FaceShape* _tmp13_;
	g_return_if_fail (IS_FACES_TOOL (self));
	g_return_if_fail (IS_FACE_SHAPE (face_shape));
	faces_tool_hide_visible_face (self);
	_tmp0_ = self->priv->editing_face_shape;
	if (_tmp0_ != NULL) {
		FaceShape* _tmp1_;
		FaceShape* _tmp2_;
		GeeHashMap* _tmp3_;
		GeeCollection* _tmp4_;
		GeeCollection* _tmp5_;
		GeeCollection* _tmp6_;
		FaceShape* _tmp7_;
		gboolean _tmp8_;
		_tmp1_ = self->priv->editing_face_shape;
		face_shape_hide (_tmp1_);
		_tmp2_ = self->priv->editing_face_shape;
		face_shape_set_editable (_tmp2_, FALSE);
		_tmp3_ = self->priv->face_shapes;
		_tmp4_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_tmp5_ = _tmp4_;
		_tmp6_ = _tmp5_;
		_tmp7_ = self->priv->editing_face_shape;
		_tmp8_ = gee_collection_contains (_tmp6_, _tmp7_);
		_g_object_unref0 (_tmp6_);
		if (_tmp8_) {
			faces_tool_set_ok_button_sensitivity (self);
		}
		_g_object_unref0 (self->priv->editing_face_shape);
		self->priv->editing_face_shape = NULL;
	}
	if (creating) {
		FacesToolFacesToolWindow* _tmp9_;
		_tmp9_ = self->priv->faces_tool_window;
		faces_tool_faces_tool_window_set_editing_phase (_tmp9_, FACES_TOOL_EDITING_PHASE_CREATING_DRAGGING, NULL);
	} else {
		FacesToolFacesToolWindow* _tmp10_;
		face_shape_show (face_shape);
		_tmp10_ = self->priv->faces_tool_window;
		faces_tool_faces_tool_window_set_editing_phase (_tmp10_, FACES_TOOL_EDITING_PHASE_EDITING, NULL);
	}
	_tmp11_ = _g_object_ref0 (face_shape);
	_g_object_unref0 (self->priv->editing_face_shape);
	self->priv->editing_face_shape = _tmp11_;
	_tmp12_ = self->priv->editing_face_shape;
	g_signal_connect (_tmp12_, "add-me-requested", (GCallback) _faces_tool_add_face_face_shape_add_me_requested, self);
	_tmp13_ = self->priv->editing_face_shape;
	g_signal_connect (_tmp13_, "delete-me-requested", (GCallback) _faces_tool_release_face_shape_face_shape_delete_me_requested, self);
}

static void
faces_tool_release_face_shape (FacesTool* self)
{
	FaceShape* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GeeCollection* _tmp4_;
	FaceShape* _tmp5_;
	gboolean _tmp6_;
	FacesToolFacesToolWindow* _tmp12_;
	FacesToolFacesToolWindow* _tmp13_;
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = self->priv->editing_face_shape;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->face_shapes;
	_tmp2_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->editing_face_shape;
	_tmp6_ = gee_collection_contains (_tmp4_, _tmp5_);
	_g_object_unref0 (_tmp4_);
	if (_tmp6_) {
		FaceShape* _tmp7_;
		FaceShape* _tmp8_;
		FaceShape* _tmp9_;
		FacesToolFaceWidget* _tmp10_;
		FacesToolFaceWidget* _tmp11_;
		_tmp7_ = self->priv->editing_face_shape;
		face_shape_hide (_tmp7_);
		_tmp8_ = self->priv->editing_face_shape;
		face_shape_set_editable (_tmp8_, FALSE);
		_tmp9_ = self->priv->editing_face_shape;
		_tmp10_ = face_shape_get_widget (_tmp9_);
		_tmp11_ = _tmp10_;
		faces_tool_face_widget_deactivate_label (_tmp11_);
		_g_object_unref0 (_tmp11_);
	}
	_g_object_unref0 (self->priv->editing_face_shape);
	self->priv->editing_face_shape = NULL;
	_tmp12_ = self->priv->faces_tool_window;
	faces_tool_faces_tool_window_set_editing_phase (_tmp12_, FACES_TOOL_EDITING_PHASE_NOT_EDITING, NULL);
	_tmp13_ = self->priv->faces_tool_window;
	gtk_window_present (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_window_get_type (), GtkWindow));
}

static void
faces_tool_hide_visible_face (FacesTool* self)
{
	g_return_if_fail (IS_FACES_TOOL (self));
	{
		GeeIterator* _face_shape_it = NULL;
		GeeHashMap* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->face_shapes;
		_tmp1_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_face_shape_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			FaceShape* face_shape = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			FaceShape* _tmp9_;
			_tmp6_ = _face_shape_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _face_shape_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			face_shape = (FaceShape*) _tmp8_;
			_tmp9_ = face_shape;
			if (face_shape_is_visible (_tmp9_)) {
				FaceShape* _tmp10_;
				_tmp10_ = face_shape;
				face_shape_hide (_tmp10_);
				_g_object_unref0 (face_shape);
				break;
			}
			_g_object_unref0 (face_shape);
		}
		_g_object_unref0 (_face_shape_it);
	}
}

static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

static void
faces_tool_on_faces_ok (FacesTool* self)
{
	GeeHashMap* _tmp0_;
	GeeMap* new_faces = NULL;
	GeeHashMap* _tmp1_;
	ModifyFacesCommand* command = NULL;
	EditingToolsPhotoCanvas* _tmp36_;
	Photo* _tmp37_;
	Photo* _tmp38_;
	GeeMap* _tmp39_;
	ModifyFacesCommand* _tmp40_;
	ModifyFacesCommand* _tmp41_;
	ModifyFacesCommand* _tmp42_;
	EditingToolsPhotoCanvas* _tmp43_;
	Photo* _tmp44_;
	Photo* _tmp45_;
	Dimensions _tmp46_ = {0};
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = self->priv->face_shapes;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = gee_hash_map_new (TYPE_FACE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, TYPE_FACE_LOCATION_DATA, (GBoxedCopyFunc) face_location_data_dup, (GDestroyNotify) face_location_data_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	new_faces = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_MAP, GeeMap);
	{
		GeeIterator* _face_shape_it = NULL;
		GeeHashMap* _tmp2_;
		GeeCollection* _tmp3_;
		GeeCollection* _tmp4_;
		GeeCollection* _tmp5_;
		GeeIterator* _tmp6_;
		GeeIterator* _tmp7_;
		_tmp2_ = self->priv->face_shapes;
		_tmp3_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_tmp4_ = _tmp3_;
		_tmp5_ = _tmp4_;
		_tmp6_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp7_ = _tmp6_;
		_g_object_unref0 (_tmp5_);
		_face_shape_it = _tmp7_;
		while (TRUE) {
			GeeIterator* _tmp8_;
			FaceShape* face_shape = NULL;
			GeeIterator* _tmp9_;
			gpointer _tmp10_;
			FaceShape* _tmp11_;
			Face* new_face = NULL;
			FaceShape* _tmp12_;
			gchar* _tmp13_;
			gchar* _tmp14_;
			Face* _tmp15_;
			Face* _tmp16_;
			gchar** face_string = NULL;
			FaceShape* _tmp17_;
			gchar* _tmp18_;
			gchar* _tmp19_;
			gchar** _tmp20_;
			gchar** _tmp21_;
			gchar** _tmp22_;
			gint _tmp22__length1;
			gint face_string_length1;
			gint _face_string_size_;
			gchar* face_vec_str = NULL;
			gchar* face_geometry = NULL;
			gchar** _tmp23_;
			gint _tmp23__length1;
			gchar* _tmp24_;
			gchar** _tmp25_;
			gint _tmp25__length1;
			const gchar* _tmp26_;
			gchar* _tmp27_;
			FaceLocationData face_data = {0};
			const gchar* _tmp28_;
			gchar* _tmp29_;
			const gchar* _tmp30_;
			gchar* _tmp31_;
			FaceLocationData _tmp32_ = {0};
			GeeMap* _tmp33_;
			Face* _tmp34_;
			FaceLocationData _tmp35_;
			_tmp8_ = _face_shape_it;
			if (!gee_iterator_next (_tmp8_)) {
				break;
			}
			_tmp9_ = _face_shape_it;
			_tmp10_ = gee_iterator_get (_tmp9_);
			face_shape = (FaceShape*) _tmp10_;
			_tmp11_ = face_shape;
			if (!face_shape_get_known (_tmp11_)) {
				_g_object_unref0 (face_shape);
				continue;
			}
			_tmp12_ = face_shape;
			_tmp13_ = face_shape_get_name (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp15_ = face_for_name (_tmp14_);
			_tmp16_ = _tmp15_;
			_g_free0 (_tmp14_);
			new_face = _tmp16_;
			_tmp17_ = face_shape;
			_tmp18_ = face_shape_serialize (_tmp17_, FALSE);
			_tmp19_ = _tmp18_;
			_tmp21_ = _tmp20_ = g_strsplit (_tmp19_, ";", 0);
			_tmp22_ = _tmp21_;
			_tmp22__length1 = _vala_array_length (_tmp20_);
			_g_free0 (_tmp19_);
			face_string = _tmp22_;
			face_string_length1 = _tmp22__length1;
			_face_string_size_ = face_string_length1;
			_tmp23_ = face_string;
			_tmp23__length1 = face_string_length1;
			_tmp24_ = _vala_g_strjoinv (";", _tmp23_ + 0, (gint) (5 - 0));
			_g_free0 (face_geometry);
			face_geometry = _tmp24_;
			_tmp25_ = face_string;
			_tmp25__length1 = face_string_length1;
			_tmp26_ = _tmp25_[5];
			_tmp27_ = g_strdup (_tmp26_);
			_g_free0 (face_vec_str);
			face_vec_str = _tmp27_;
			_tmp28_ = face_geometry;
			_tmp29_ = g_strdup (_tmp28_);
			_tmp30_ = face_vec_str;
			_tmp31_ = g_strdup (_tmp30_);
			_g_free0 (_tmp32_.geometry);
			_tmp32_.geometry = _tmp29_;
			_g_free0 (_tmp32_.vec);
			_tmp32_.vec = _tmp31_;
			face_data = _tmp32_;
			_tmp33_ = new_faces;
			_tmp34_ = new_face;
			_tmp35_ = face_data;
			gee_map_set (_tmp33_, _tmp34_, &_tmp35_);
			face_location_data_destroy (&face_data);
			_g_free0 (face_geometry);
			_g_free0 (face_vec_str);
			face_string = (_vala_array_free (face_string, face_string_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (new_face);
			_g_object_unref0 (face_shape);
		}
		_g_object_unref0 (_face_shape_it);
	}
	_tmp36_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp37_ = editing_tools_photo_canvas_get_photo (_tmp36_);
	_tmp38_ = _tmp37_;
	_tmp39_ = new_faces;
	_tmp40_ = modify_faces_command_new (G_TYPE_CHECK_INSTANCE_CAST (_tmp38_, TYPE_MEDIA_SOURCE, MediaSource), _tmp39_);
	_tmp41_ = _tmp40_;
	_g_object_unref0 (_tmp38_);
	command = _tmp41_;
	_tmp42_ = command;
	_tmp43_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
	_tmp44_ = editing_tools_photo_canvas_get_photo (_tmp43_);
	_tmp45_ = _tmp44_;
	media_source_get_dimensions (G_TYPE_CHECK_INSTANCE_CAST (_tmp45_, TYPE_MEDIA_SOURCE, MediaSource), PHOTO_EXCEPTION_NONE, &_tmp46_);
	g_signal_emit_by_name (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool), "applied", G_TYPE_CHECK_INSTANCE_CAST (_tmp42_, TYPE_COMMAND, Command), NULL, &_tmp46_, FALSE);
	_g_object_unref0 (_tmp45_);
	_g_object_unref0 (command);
	_g_object_unref0 (new_faces);
}

static void
faces_tool_on_face_hidden (FacesTool* self)
{
	FaceShape* _tmp0_;
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = self->priv->editing_face_shape;
	if (_tmp0_ != NULL) {
		FaceShape* _tmp1_;
		_tmp1_ = self->priv->editing_face_shape;
		face_shape_show (_tmp1_);
	}
}

static void
faces_tool_add_face (FacesTool* self,
                     FaceShape* face_shape)
{
	gchar* prepared_face_name = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (IS_FACES_TOOL (self));
	g_return_if_fail (IS_FACE_SHAPE (face_shape));
	_tmp0_ = face_shape_get_name (face_shape);
	_tmp1_ = _tmp0_;
	_tmp2_ = face_prep_face_name (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	prepared_face_name = _tmp3_;
	_tmp4_ = prepared_face_name;
	if (_tmp4_ != NULL) {
		const gchar* _tmp5_;
		GeeHashMap* _tmp6_;
		GeeCollection* _tmp7_;
		GeeCollection* _tmp8_;
		GeeCollection* _tmp9_;
		gboolean _tmp10_;
		_tmp5_ = prepared_face_name;
		face_shape_set_name (face_shape, _tmp5_);
		_tmp6_ = self->priv->face_shapes;
		_tmp7_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_tmp8_ = _tmp7_;
		_tmp9_ = _tmp8_;
		_tmp10_ = gee_collection_contains (_tmp9_, face_shape);
		_g_object_unref0 (_tmp9_);
		if (_tmp10_) {
			{
				GeeIterator* _entry_it = NULL;
				GeeHashMap* _tmp11_;
				GeeSet* _tmp12_;
				GeeSet* _tmp13_;
				GeeSet* _tmp14_;
				GeeIterator* _tmp15_;
				GeeIterator* _tmp16_;
				_tmp11_ = self->priv->face_shapes;
				_tmp12_ = gee_abstract_map_get_entries (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
				_tmp13_ = _tmp12_;
				_tmp14_ = _tmp13_;
				_tmp15_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, GEE_TYPE_ITERABLE, GeeIterable));
				_tmp16_ = _tmp15_;
				_g_object_unref0 (_tmp14_);
				_entry_it = _tmp16_;
				while (TRUE) {
					GeeIterator* _tmp17_;
					GeeMapEntry* entry = NULL;
					GeeIterator* _tmp18_;
					gpointer _tmp19_;
					GeeMapEntry* _tmp20_;
					gconstpointer _tmp21_;
					gconstpointer _tmp22_;
					_tmp17_ = _entry_it;
					if (!gee_iterator_next (_tmp17_)) {
						break;
					}
					_tmp18_ = _entry_it;
					_tmp19_ = gee_iterator_get (_tmp18_);
					entry = (GeeMapEntry*) _tmp19_;
					_tmp20_ = entry;
					_tmp21_ = gee_map_entry_get_value (_tmp20_);
					_tmp22_ = _tmp21_;
					if (((FaceShape*) _tmp22_) == face_shape) {
						GeeMapEntry* _tmp23_;
						gconstpointer _tmp24_;
						gconstpointer _tmp25_;
						const gchar* _tmp26_;
						GeeHashMap* _tmp27_;
						GeeMapEntry* _tmp28_;
						gconstpointer _tmp29_;
						gconstpointer _tmp30_;
						GeeHashMap* _tmp31_;
						const gchar* _tmp32_;
						FacesToolFaceWidget* _tmp33_;
						FacesToolFaceWidget* _tmp34_;
						GtkLabel* _tmp35_;
						gchar* _tmp36_;
						gchar* _tmp37_;
						_tmp23_ = entry;
						_tmp24_ = gee_map_entry_get_key (_tmp23_);
						_tmp25_ = _tmp24_;
						_tmp26_ = prepared_face_name;
						if (g_strcmp0 ((const gchar*) _tmp25_, _tmp26_) == 0) {
							_g_object_unref0 (entry);
							break;
						}
						_tmp27_ = self->priv->face_shapes;
						_tmp28_ = entry;
						_tmp29_ = gee_map_entry_get_key (_tmp28_);
						_tmp30_ = _tmp29_;
						gee_abstract_map_unset (G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), (const gchar*) _tmp30_, NULL);
						_tmp31_ = self->priv->face_shapes;
						_tmp32_ = prepared_face_name;
						gee_abstract_map_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), _tmp32_, face_shape);
						face_shape_set_known (face_shape, TRUE);
						_tmp33_ = face_shape_get_widget (face_shape);
						_tmp34_ = _tmp33_;
						_tmp35_ = _tmp34_->label;
						_tmp36_ = face_shape_get_name (face_shape);
						_tmp37_ = _tmp36_;
						gtk_label_set_text (_tmp35_, _tmp37_);
						_g_free0 (_tmp37_);
						_g_object_unref0 (_tmp34_);
						_g_object_unref0 (entry);
						break;
					}
					_g_object_unref0 (entry);
				}
				_g_object_unref0 (_entry_it);
			}
		} else {
			GeeHashMap* _tmp38_;
			const gchar* _tmp39_;
			_tmp38_ = self->priv->face_shapes;
			_tmp39_ = prepared_face_name;
			if (!gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp38_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), _tmp39_)) {
				FacesToolFacesToolWindow* _tmp40_;
				GeeHashMap* _tmp41_;
				const gchar* _tmp42_;
				_tmp40_ = self->priv->faces_tool_window;
				faces_tool_faces_tool_window_add_face (_tmp40_, face_shape);
				_tmp41_ = self->priv->face_shapes;
				_tmp42_ = prepared_face_name;
				gee_abstract_map_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), _tmp42_, face_shape);
			} else {
				_g_free0 (prepared_face_name);
				return;
			}
		}
		face_shape_hide (face_shape);
		face_shape_set_editable (face_shape, FALSE);
		faces_tool_set_ok_button_sensitivity (self);
		faces_tool_release_face_shape (self);
	}
	_g_free0 (prepared_face_name);
}

static void
faces_tool_edit_face (FacesTool* self,
                      const gchar* face_name)
{
	FaceShape* face_shape = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	g_return_if_fail (IS_FACES_TOOL (self));
	g_return_if_fail (face_name != NULL);
	_tmp0_ = self->priv->face_shapes;
	_tmp1_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), face_name);
	face_shape = (FaceShape*) _tmp1_;
	_vala_assert (face_shape != NULL, "face_shape != null");
	face_shape_set_editable (face_shape, TRUE);
	faces_tool_edit_face_shape (self, face_shape, FALSE);
	_g_object_unref0 (face_shape);
}

static void
faces_tool_delete_face (FacesTool* self,
                        const gchar* face_name)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (IS_FACES_TOOL (self));
	g_return_if_fail (face_name != NULL);
	_tmp0_ = self->priv->face_shapes;
	gee_abstract_map_unset (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), face_name, NULL);
	{
		GeeIterator* _face_shape_it = NULL;
		GeeHashMap* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeCollection* _tmp4_;
		GeeIterator* _tmp5_;
		GeeIterator* _tmp6_;
		_tmp1_ = self->priv->face_shapes;
		_tmp2_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp5_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp6_ = _tmp5_;
		_g_object_unref0 (_tmp4_);
		_face_shape_it = _tmp6_;
		while (TRUE) {
			GeeIterator* _tmp7_;
			FaceShape* face_shape = NULL;
			GeeIterator* _tmp8_;
			gpointer _tmp9_;
			FaceShape* _tmp10_;
			_tmp7_ = _face_shape_it;
			if (!gee_iterator_next (_tmp7_)) {
				break;
			}
			_tmp8_ = _face_shape_it;
			_tmp9_ = gee_iterator_get (_tmp8_);
			face_shape = (FaceShape*) _tmp9_;
			_tmp10_ = face_shape;
			if (face_shape_is_visible (_tmp10_)) {
				FaceShape* _tmp11_;
				FaceShape* _tmp12_;
				_tmp11_ = face_shape;
				face_shape_hide (_tmp11_);
				_tmp12_ = face_shape;
				face_shape_show (_tmp12_);
				_g_object_unref0 (face_shape);
				break;
			}
			_g_object_unref0 (face_shape);
		}
		_g_object_unref0 (_face_shape_it);
	}
	faces_tool_set_ok_button_sensitivity (self);
}

static void
faces_tool_set_ok_button_sensitivity (FacesTool* self)
{
	GeeMap* known_face_shapes = NULL;
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp20_;
	gint _tmp21_;
	gint _tmp22_;
	GeeMap* _tmp23_;
	gint _tmp24_;
	gint _tmp25_;
	FacesToolFacesToolWindow* _tmp62_;
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, TYPE_FACE_SHAPE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	known_face_shapes = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_MAP, GeeMap);
	{
		GeeIterator* _face_shape_it = NULL;
		GeeHashMap* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeSet* _tmp4_;
		GeeIterator* _tmp5_;
		GeeIterator* _tmp6_;
		_tmp1_ = self->priv->face_shapes;
		_tmp2_ = gee_abstract_map_get_entries (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp5_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp6_ = _tmp5_;
		_g_object_unref0 (_tmp4_);
		_face_shape_it = _tmp6_;
		while (TRUE) {
			GeeIterator* _tmp7_;
			GeeMapEntry* face_shape = NULL;
			GeeIterator* _tmp8_;
			gpointer _tmp9_;
			GeeMapEntry* _tmp10_;
			gconstpointer _tmp11_;
			gconstpointer _tmp12_;
			_tmp7_ = _face_shape_it;
			if (!gee_iterator_next (_tmp7_)) {
				break;
			}
			_tmp8_ = _face_shape_it;
			_tmp9_ = gee_iterator_get (_tmp8_);
			face_shape = (GeeMapEntry*) _tmp9_;
			_tmp10_ = face_shape;
			_tmp11_ = gee_map_entry_get_value (_tmp10_);
			_tmp12_ = _tmp11_;
			if (face_shape_get_known ((FaceShape*) _tmp12_)) {
				GeeMap* _tmp13_;
				GeeMapEntry* _tmp14_;
				gconstpointer _tmp15_;
				gconstpointer _tmp16_;
				GeeMapEntry* _tmp17_;
				gconstpointer _tmp18_;
				gconstpointer _tmp19_;
				_tmp13_ = known_face_shapes;
				_tmp14_ = face_shape;
				_tmp15_ = gee_map_entry_get_key (_tmp14_);
				_tmp16_ = _tmp15_;
				_tmp17_ = face_shape;
				_tmp18_ = gee_map_entry_get_value (_tmp17_);
				_tmp19_ = _tmp18_;
				gee_map_set (_tmp13_, (const gchar*) _tmp16_, (FaceShape*) _tmp19_);
			}
			_g_object_unref0 (face_shape);
		}
		_g_object_unref0 (_face_shape_it);
	}
	_tmp20_ = self->priv->original_face_locations;
	_tmp21_ = gee_abstract_map_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
	_tmp22_ = _tmp21_;
	_tmp23_ = known_face_shapes;
	_tmp24_ = gee_map_get_size (_tmp23_);
	_tmp25_ = _tmp24_;
	if (_tmp22_ != _tmp25_) {
		FacesToolFacesToolWindow* _tmp26_;
		_tmp26_ = self->priv->faces_tool_window;
		faces_tool_faces_tool_window_ok_button_set_sensitive (_tmp26_, TRUE);
		_g_object_unref0 (known_face_shapes);
		return;
	}
	{
		GeeIterator* _face_shape_it = NULL;
		GeeMap* _tmp27_;
		GeeSet* _tmp28_;
		GeeSet* _tmp29_;
		GeeSet* _tmp30_;
		GeeIterator* _tmp31_;
		GeeIterator* _tmp32_;
		_tmp27_ = known_face_shapes;
		_tmp28_ = gee_map_get_entries (_tmp27_);
		_tmp29_ = _tmp28_;
		_tmp30_ = _tmp29_;
		_tmp31_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp32_ = _tmp31_;
		_g_object_unref0 (_tmp30_);
		_face_shape_it = _tmp32_;
		while (TRUE) {
			GeeIterator* _tmp33_;
			GeeMapEntry* face_shape = NULL;
			GeeIterator* _tmp34_;
			gpointer _tmp35_;
			gboolean found = FALSE;
			_tmp33_ = _face_shape_it;
			if (!gee_iterator_next (_tmp33_)) {
				break;
			}
			_tmp34_ = _face_shape_it;
			_tmp35_ = gee_iterator_get (_tmp34_);
			face_shape = (GeeMapEntry*) _tmp35_;
			found = FALSE;
			{
				GeeIterator* _face_location_it = NULL;
				GeeHashMap* _tmp36_;
				GeeSet* _tmp37_;
				GeeSet* _tmp38_;
				GeeSet* _tmp39_;
				GeeIterator* _tmp40_;
				GeeIterator* _tmp41_;
				_tmp36_ = self->priv->original_face_locations;
				_tmp37_ = gee_abstract_map_get_entries (G_TYPE_CHECK_INSTANCE_CAST (_tmp36_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
				_tmp38_ = _tmp37_;
				_tmp39_ = _tmp38_;
				_tmp40_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp39_, GEE_TYPE_ITERABLE, GeeIterable));
				_tmp41_ = _tmp40_;
				_g_object_unref0 (_tmp39_);
				_face_location_it = _tmp41_;
				while (TRUE) {
					GeeIterator* _tmp42_;
					GeeMapEntry* face_location = NULL;
					GeeIterator* _tmp43_;
					gpointer _tmp44_;
					GeeMapEntry* _tmp45_;
					gconstpointer _tmp46_;
					gconstpointer _tmp47_;
					GeeMapEntry* _tmp48_;
					gconstpointer _tmp49_;
					gconstpointer _tmp50_;
					_tmp42_ = _face_location_it;
					if (!gee_iterator_next (_tmp42_)) {
						break;
					}
					_tmp43_ = _face_location_it;
					_tmp44_ = gee_iterator_get (_tmp43_);
					face_location = (GeeMapEntry*) _tmp44_;
					_tmp45_ = face_location;
					_tmp46_ = gee_map_entry_get_key (_tmp45_);
					_tmp47_ = _tmp46_;
					_tmp48_ = face_shape;
					_tmp49_ = gee_map_entry_get_key (_tmp48_);
					_tmp50_ = _tmp49_;
					if (g_strcmp0 ((const gchar*) _tmp47_, (const gchar*) _tmp50_) == 0) {
						GeeMapEntry* _tmp51_;
						gconstpointer _tmp52_;
						gconstpointer _tmp53_;
						GeeMapEntry* _tmp54_;
						gconstpointer _tmp55_;
						gconstpointer _tmp56_;
						gchar* _tmp57_;
						gchar* _tmp58_;
						gboolean _tmp59_;
						_tmp51_ = face_location;
						_tmp52_ = gee_map_entry_get_value (_tmp51_);
						_tmp53_ = _tmp52_;
						_tmp54_ = face_shape;
						_tmp55_ = gee_map_entry_get_value (_tmp54_);
						_tmp56_ = _tmp55_;
						_tmp57_ = face_shape_serialize ((FaceShape*) _tmp56_, FALSE);
						_tmp58_ = _tmp57_;
						_tmp59_ = g_strcmp0 ((const gchar*) _tmp53_, _tmp58_) == 0;
						_g_free0 (_tmp58_);
						if (_tmp59_) {
							found = TRUE;
							_g_object_unref0 (face_location);
							break;
						} else {
							FacesToolFacesToolWindow* _tmp60_;
							_tmp60_ = self->priv->faces_tool_window;
							faces_tool_faces_tool_window_ok_button_set_sensitive (_tmp60_, TRUE);
							_g_object_unref0 (face_location);
							_g_object_unref0 (_face_location_it);
							_g_object_unref0 (face_shape);
							_g_object_unref0 (_face_shape_it);
							_g_object_unref0 (known_face_shapes);
							return;
						}
					}
					_g_object_unref0 (face_location);
				}
				_g_object_unref0 (_face_location_it);
			}
			if (!found) {
				FacesToolFacesToolWindow* _tmp61_;
				_tmp61_ = self->priv->faces_tool_window;
				faces_tool_faces_tool_window_ok_button_set_sensitive (_tmp61_, TRUE);
				_g_object_unref0 (face_shape);
				_g_object_unref0 (_face_shape_it);
				_g_object_unref0 (known_face_shapes);
				return;
			}
			_g_object_unref0 (face_shape);
		}
		_g_object_unref0 (_face_shape_it);
	}
	_tmp62_ = self->priv->faces_tool_window;
	faces_tool_faces_tool_window_ok_button_set_sensitive (_tmp62_, FALSE);
	_g_object_unref0 (known_face_shapes);
}

static void
faces_tool_detect_faces (FacesTool* self)
{
	FacesToolFacesToolWindow* _tmp0_;
	GtkButton* _tmp1_;
	FacesToolFacesToolWindow* _tmp2_;
	Workers* _tmp3_;
	FacesToolFaceDetectionJob* _tmp4_;
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = self->priv->faces_tool_window;
	_tmp1_ = _tmp0_->detection_button;
	gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget), FALSE);
	_tmp2_ = self->priv->faces_tool_window;
	faces_tool_faces_tool_window_set_editing_phase (_tmp2_, FACES_TOOL_EDITING_PHASE_DETECTING_FACES, NULL);
	_tmp3_ = self->priv->workers;
	_tmp4_ = self->priv->face_detection;
	workers_enqueue (_tmp3_, G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, TYPE_BACKGROUND_JOB, BackgroundJob));
}

static void
faces_tool_pick_faces_from_autodetected (FacesTool* self)
{
	gint c = 0;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (IS_FACES_TOOL (self));
	c = 0;
	while (TRUE) {
		gchar* serialized_geometry = NULL;
		FacesToolFaceDetectionJob* _tmp0_;
		gchar* _tmp1_;
		const gchar* _tmp2_;
		FaceShape* face_shape = NULL;
		gboolean found = FALSE;
		gint _tmp21_;
		Face* guess = NULL;
		FaceShape* _tmp22_;
		Face* _tmp23_;
		Face* _tmp24_;
		FaceShape* _tmp37_;
		_tmp0_ = self->priv->face_detection;
		_tmp1_ = faces_tool_face_detection_job_get_next (_tmp0_);
		serialized_geometry = _tmp1_;
		_tmp2_ = serialized_geometry;
		if (_tmp2_ == NULL) {
			FacesToolFacesToolWindow* _tmp3_;
			_tmp3_ = self->priv->faces_tool_window;
			faces_tool_faces_tool_window_set_editing_phase (_tmp3_, FACES_TOOL_EDITING_PHASE_DETECTING_FACES_FINISHED, NULL);
			_g_free0 (serialized_geometry);
			return;
		}
		{
			FaceShape* _tmp4_ = NULL;
			EditingToolsPhotoCanvas* _tmp5_;
			const gchar* _tmp6_;
			FaceShape* _tmp7_;
			FaceShape* _tmp8_;
			_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL, EditingToolsEditingTool)->canvas;
			_tmp6_ = serialized_geometry;
			_tmp7_ = face_shape_from_serialized (_tmp5_, _tmp6_, &_inner_error0_);
			_tmp4_ = _tmp7_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				if (_inner_error0_->domain == FACE_SHAPE_ERROR) {
					goto __catch0_face_shape_error;
				}
				_g_object_unref0 (face_shape);
				_g_free0 (serialized_geometry);
				g_critical ("file %s: line %d: unexpected 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;
			}
			_tmp8_ = _tmp4_;
			_tmp4_ = NULL;
			_g_object_unref0 (face_shape);
			face_shape = _tmp8_;
			_g_object_unref0 (_tmp4_);
		}
		goto __finally0;
		__catch0_face_shape_error:
		{
			GError* e = NULL;
			GError* _tmp9_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp9_ = e;
			if (g_error_matches (_tmp9_, FACE_SHAPE_ERROR, FACE_SHAPE_ERROR_CANT_CREATE)) {
				_g_error_free0 (e);
				_g_object_unref0 (face_shape);
				_g_free0 (serialized_geometry);
				continue;
			}
			g_assert_not_reached ();
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (face_shape);
			_g_free0 (serialized_geometry);
			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;
		}
		found = FALSE;
		{
			GeeIterator* _existing_face_shape_it = NULL;
			GeeHashMap* _tmp10_;
			GeeCollection* _tmp11_;
			GeeCollection* _tmp12_;
			GeeCollection* _tmp13_;
			GeeIterator* _tmp14_;
			GeeIterator* _tmp15_;
			_tmp10_ = self->priv->face_shapes;
			_tmp11_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
			_tmp12_ = _tmp11_;
			_tmp13_ = _tmp12_;
			_tmp14_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GEE_TYPE_ITERABLE, GeeIterable));
			_tmp15_ = _tmp14_;
			_g_object_unref0 (_tmp13_);
			_existing_face_shape_it = _tmp15_;
			while (TRUE) {
				GeeIterator* _tmp16_;
				FaceShape* existing_face_shape = NULL;
				GeeIterator* _tmp17_;
				gpointer _tmp18_;
				FaceShape* _tmp19_;
				FaceShape* _tmp20_;
				_tmp16_ = _existing_face_shape_it;
				if (!gee_iterator_next (_tmp16_)) {
					break;
				}
				_tmp17_ = _existing_face_shape_it;
				_tmp18_ = gee_iterator_get (_tmp17_);
				existing_face_shape = (FaceShape*) _tmp18_;
				_tmp19_ = existing_face_shape;
				_tmp20_ = face_shape;
				if (face_shape_equals (_tmp19_, _tmp20_)) {
					found = TRUE;
					_g_object_unref0 (existing_face_shape);
					break;
				}
				_g_object_unref0 (existing_face_shape);
			}
			_g_object_unref0 (_existing_face_shape_it);
		}
		if (found) {
			_g_object_unref0 (face_shape);
			_g_free0 (serialized_geometry);
			continue;
		}
		_tmp21_ = c;
		c = _tmp21_ + 1;
		_tmp22_ = face_shape;
		_tmp23_ = faces_tool_get_face_match (self, _tmp22_, 0.7);
		guess = _tmp23_;
		_tmp24_ = guess;
		if (_tmp24_ == NULL) {
			FaceShape* _tmp25_;
			gchar* _tmp26_;
			gchar* _tmp27_;
			FaceShape* _tmp28_;
			_tmp25_ = face_shape;
			_tmp26_ = g_strdup_printf ("Unknown face #%d", c);
			_tmp27_ = _tmp26_;
			face_shape_set_name (_tmp25_, _tmp27_);
			_g_free0 (_tmp27_);
			_tmp28_ = face_shape;
			face_shape_set_known (_tmp28_, FALSE);
		} else {
			gchar* name_str = NULL;
			Face* _tmp29_;
			gchar* _tmp30_;
			gchar* _tmp31_;
			FaceShape* _tmp32_;
			gchar* _tmp33_;
			FaceShape* _tmp34_;
			const gchar* _tmp35_;
			FaceShape* _tmp36_;
			_tmp29_ = guess;
			_tmp30_ = data_object_get_name (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, TYPE_DATA_OBJECT, DataObject));
			_tmp31_ = _tmp30_;
			_tmp32_ = face_shape;
			_tmp33_ = g_strdup_printf ("%s (%0.2f%%)", _tmp31_, face_shape_get_guess (_tmp32_) * 100);
			_g_free0 (name_str);
			name_str = _tmp33_;
			_g_free0 (_tmp31_);
			_tmp34_ = face_shape;
			_tmp35_ = name_str;
			face_shape_set_name (_tmp34_, _tmp35_);
			_tmp36_ = face_shape;
			face_shape_set_known (_tmp36_, TRUE);
			_g_free0 (name_str);
		}
		_tmp37_ = face_shape;
		faces_tool_add_face (self, _tmp37_);
		_g_object_unref0 (guess);
		_g_object_unref0 (face_shape);
		_g_free0 (serialized_geometry);
	}
}

static gdouble
faces_tool_dot_product (FacesTool* self,
                        gdouble* vec1,
                        gint vec1_length1,
                        gdouble* vec2,
                        gint vec2_length1)
{
	gdouble ret = 0.0;
	gdouble result;
	g_return_val_if_fail (IS_FACES_TOOL (self), -1.0);
	if (vec1_length1 != vec2_length1) {
		result = (gdouble) 0;
		return result;
	}
	ret = (gdouble) 0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gdouble _tmp2_;
				gdouble _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < vec1_length1)) {
					break;
				}
				_tmp2_ = vec1[i];
				_tmp3_ = vec2[i];
				ret += _tmp2_ * _tmp3_;
			}
		}
	}
	result = ret;
	return result;
}

static gdouble
double_parse (const gchar* str)
{
	gdouble result;
	g_return_val_if_fail (str != NULL, -1.0);
	result = g_ascii_strtod (str, NULL);
	return result;
}

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

static gpointer
_face_id_dup0 (gpointer self)
{
	return self ? face_id_dup (self) : NULL;
}

static Face*
faces_tool_get_face_match (FacesTool* self,
                           FaceShape* face_shape,
                           gdouble threshold)
{
	GeeList* face_vecs = NULL;
	FaceID* guess_id = NULL;
	gdouble max_product = 0.0;
	Face* face = NULL;
	FaceID* _tmp35_;
	GError* _inner_error0_ = NULL;
	Face* result;
	g_return_val_if_fail (IS_FACES_TOOL (self), NULL);
	g_return_val_if_fail (IS_FACE_SHAPE (face_shape), NULL);
	{
		GeeList* face_rows = NULL;
		FaceTable* _tmp0_;
		FaceTable* _tmp1_;
		GeeList* _tmp2_;
		GeeList* _tmp3_;
		GeeList* _tmp4_ = NULL;
		FaceLocationTable* _tmp5_;
		FaceLocationTable* _tmp6_;
		GeeList* _tmp7_;
		GeeList* _tmp8_;
		GeeList* _tmp9_;
		GeeList* _tmp10_;
		_tmp0_ = face_table_get_instance ();
		_tmp1_ = _tmp0_;
		_tmp2_ = face_table_get_ref_rows (_tmp1_, &_inner_error0_);
		_tmp3_ = _tmp2_;
		_database_table_unref0 (_tmp1_);
		face_rows = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == DATABASE_ERROR) {
				goto __catch0_database_error;
			}
			_g_object_unref0 (face_vecs);
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp5_ = face_location_table_get_instance ();
		_tmp6_ = _tmp5_;
		_tmp7_ = face_rows;
		_tmp8_ = face_location_table_get_face_ref_vecs (_tmp6_, _tmp7_, &_inner_error0_);
		_tmp9_ = _tmp8_;
		_database_table_unref0 (_tmp6_);
		_tmp4_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (face_rows);
			if (_inner_error0_->domain == DATABASE_ERROR) {
				goto __catch0_database_error;
			}
			_g_object_unref0 (face_vecs);
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp10_ = _tmp4_;
		_tmp4_ = NULL;
		_g_object_unref0 (face_vecs);
		face_vecs = _tmp10_;
		_g_object_unref0 (_tmp4_);
		_g_object_unref0 (face_rows);
	}
	goto __finally0;
	__catch0_database_error:
	{
		g_clear_error (&_inner_error0_);
		g_warning ("FacesTool.vala:934: Cannot get reference faces from DB");
		result = NULL;
		_g_object_unref0 (face_vecs);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (face_vecs);
		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 NULL;
	}
	guess_id = NULL;
	max_product = threshold;
	{
		GeeList* _row_list = NULL;
		GeeList* _tmp11_;
		gint _row_size = 0;
		GeeList* _tmp12_;
		gint _tmp13_;
		gint _tmp14_;
		gint _row_index = 0;
		_tmp11_ = face_vecs;
		_row_list = _tmp11_;
		_tmp12_ = _row_list;
		_tmp13_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp14_ = _tmp13_;
		_row_size = _tmp14_;
		_row_index = -1;
		while (TRUE) {
			gint _tmp15_;
			gint _tmp16_;
			FaceLocationRow* row = NULL;
			GeeList* _tmp17_;
			gpointer _tmp18_;
			gchar** vec_str = NULL;
			FaceLocationRow* _tmp19_;
			const gchar* _tmp20_;
			gchar** _tmp21_;
			gchar** _tmp22_;
			gint vec_str_length1;
			gint _vec_str_size_;
			gdouble* vec = NULL;
			gdouble* _tmp23_;
			gint vec_length1;
			gint _vec_size_;
			gchar** _tmp24_;
			gint _tmp24__length1;
			gdouble product = 0.0;
			gint _tmp27_ = 0;
			gdouble* _tmp28_;
			gdouble* _tmp29_;
			gint _tmp29__length1;
			gdouble* _tmp30_;
			gint _tmp30__length1;
			gdouble _tmp31_;
			_row_index = _row_index + 1;
			_tmp15_ = _row_index;
			_tmp16_ = _row_size;
			if (!(_tmp15_ < _tmp16_)) {
				break;
			}
			_tmp17_ = _row_list;
			_tmp18_ = gee_list_get (_tmp17_, _row_index);
			row = (FaceLocationRow*) _tmp18_;
			_tmp19_ = row;
			_tmp20_ = _tmp19_->vec;
			_tmp22_ = _tmp21_ = g_strsplit (_tmp20_, ",", 0);
			vec_str = _tmp22_;
			vec_str_length1 = _vala_array_length (_tmp21_);
			_vec_str_size_ = vec_str_length1;
			_tmp23_ = g_new0 (gdouble, 0);
			vec = _tmp23_;
			vec_length1 = 0;
			_vec_size_ = vec_length1;
			_tmp24_ = vec_str;
			_tmp24__length1 = vec_str_length1;
			{
				gchar** d_collection = NULL;
				gint d_collection_length1 = 0;
				gint _d_collection_size_ = 0;
				gint d_it = 0;
				d_collection = _tmp24_;
				d_collection_length1 = _tmp24__length1;
				for (d_it = 0; d_it < d_collection_length1; d_it = d_it + 1) {
					gchar* _tmp25_;
					gchar* d = NULL;
					_tmp25_ = g_strdup (d_collection[d_it]);
					d = _tmp25_;
					{
						const gchar* _tmp26_;
						_tmp26_ = d;
						_vala_array_add135 (&vec, &vec_length1, &_vec_size_, double_parse (_tmp26_));
						_g_free0 (d);
					}
				}
			}
			_tmp28_ = face_shape_get_face_vec (face_shape, &_tmp27_);
			_tmp29_ = _tmp28_;
			_tmp29__length1 = _tmp27_;
			_tmp30_ = vec;
			_tmp30__length1 = vec_length1;
			_tmp31_ = faces_tool_dot_product (self, _tmp29_, (gint) _tmp27_, _tmp30_ + 0, (gint) (128 - 0));
			_tmp29_ = (g_free (_tmp29_), NULL);
			product = _tmp31_;
			if (product > max_product) {
				FaceLocationRow* _tmp32_;
				FaceID _tmp33_;
				FaceID* _tmp34_;
				max_product = product;
				_tmp32_ = row;
				_tmp33_ = _tmp32_->face_id;
				_tmp34_ = _face_id_dup0 (&_tmp33_);
				_face_id_free0 (guess_id);
				guess_id = _tmp34_;
			}
			vec = (g_free (vec), NULL);
			vec_str = (_vala_array_free (vec_str, vec_str_length1, (GDestroyNotify) g_free), NULL);
			_face_location_row_unref0 (row);
		}
	}
	face = NULL;
	_tmp35_ = guess_id;
	if (_tmp35_ != NULL) {
		FaceSourceCollection* _tmp36_;
		FaceID* _tmp37_;
		FaceID _tmp38_;
		Face* _tmp39_;
		Face* _tmp40_;
		_tmp36_ = face_global;
		_tmp37_ = guess_id;
		_tmp38_ = *_tmp37_;
		_tmp39_ = face_source_collection_fetch (_tmp36_, &_tmp38_);
		_g_object_unref0 (face);
		face = _tmp39_;
		face_shape_set_guess (face_shape, max_product);
		_tmp40_ = face;
		_vala_assert (_tmp40_ != NULL, "face != null");
	}
	result = face;
	_face_id_free0 (guess_id);
	_g_object_unref0 (face_vecs);
	return result;
}

static void
faces_tool_on_faces_detected (FacesTool* self)
{
	GCancellable* _tmp0_;
	FacesToolFaceDetectionJob* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = self->priv->face_detection_cancellable;
	g_cancellable_reset (_tmp0_);
	_tmp1_ = self->priv->face_detection;
	_tmp2_ = _tmp1_->spawnError;
	if (_tmp2_ != NULL) {
		gchar* spawnErrorMessage = NULL;
		gchar* _tmp3_;
		const gchar* _tmp4_;
		FacesToolFaceDetectionJob* _tmp5_;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		FacesToolFacesToolWindow* _tmp11_;
		_tmp3_ = g_strdup (_ ("Error trying to spawn face detection program:\n"));
		spawnErrorMessage = _tmp3_;
		_tmp4_ = spawnErrorMessage;
		_tmp5_ = self->priv->face_detection;
		_tmp6_ = _tmp5_->spawnError;
		_tmp7_ = g_strconcat (_tmp4_, _tmp6_, NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_strconcat (_tmp8_, "\n", NULL);
		_tmp10_ = _tmp9_;
		app_window_error_message (_tmp10_, NULL);
		_g_free0 (_tmp10_);
		_g_free0 (_tmp8_);
		_tmp11_ = self->priv->faces_tool_window;
		faces_tool_faces_tool_window_set_editing_phase (_tmp11_, FACES_TOOL_EDITING_PHASE_DETECTING_FACES_FINISHED, NULL);
		_g_free0 (spawnErrorMessage);
	} else {
		faces_tool_pick_faces_from_autodetected (self);
	}
}

static void
faces_tool_on_detection_cancelled (FacesTool* self,
                                   BackgroundJob* job)
{
	GCancellable* _tmp0_;
	FacesToolFacesToolWindow* _tmp1_;
	g_return_if_fail (IS_FACES_TOOL (self));
	g_return_if_fail (IS_BACKGROUND_JOB (job));
	faces_tool_face_detection_job_reset (G_TYPE_CHECK_INSTANCE_CAST (job, FACES_TOOL_TYPE_FACE_DETECTION_JOB, FacesToolFaceDetectionJob));
	_tmp0_ = self->priv->face_detection_cancellable;
	g_cancellable_reset (_tmp0_);
	_tmp1_ = self->priv->faces_tool_window;
	faces_tool_faces_tool_window_set_editing_phase (_tmp1_, FACES_TOOL_EDITING_PHASE_DETECTING_FACES_FINISHED, NULL);
}

static void
faces_tool_cancel_face_detection (FacesTool* self)
{
	FacesToolFacesToolWindow* _tmp0_;
	GtkButton* _tmp1_;
	FacesToolFaceDetectionJob* _tmp2_;
	g_return_if_fail (IS_FACES_TOOL (self));
	_tmp0_ = self->priv->faces_tool_window;
	_tmp1_ = _tmp0_->cancel_detection_button;
	gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget), FALSE);
	_tmp2_ = self->priv->face_detection;
	background_job_cancel (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, TYPE_BACKGROUND_JOB, BackgroundJob));
}

FacesToolFaceWidget*
faces_tool_face_widget_construct (GType object_type,
                                  FaceShape* face_shape)
{
	FacesToolFaceWidget * self = NULL;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkButton* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkButton* _tmp12_;
	GtkButton* _tmp13_;
	g_return_val_if_fail (IS_FACE_SHAPE (face_shape), NULL);
	self = (FacesToolFaceWidget*) g_object_new (object_type, NULL);
	gtk_box_set_spacing (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), FACES_TOOL_CONTROL_SPACING);
	_tmp0_ = (GtkButton*) gtk_button_new_with_label (RESOURCES_EDIT_LABEL);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->edit_button);
	self->edit_button = _tmp0_;
	_tmp1_ = self->edit_button;
	gtk_button_set_use_underline (_tmp1_, TRUE);
	_tmp2_ = (GtkButton*) gtk_button_new_with_label (RESOURCES_DELETE_LABEL);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->delete_button);
	self->delete_button = _tmp2_;
	_tmp3_ = self->delete_button;
	gtk_button_set_use_underline (_tmp3_, TRUE);
	_tmp4_ = face_shape_get_name (face_shape);
	_tmp5_ = _tmp4_;
	_tmp6_ = (GtkLabel*) gtk_label_new (_tmp5_);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->label);
	self->label = _tmp6_;
	_g_free0 (_tmp5_);
	_tmp7_ = self->label;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	_tmp8_ = self->label;
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	_tmp9_ = self->label;
	gtk_label_set_ellipsize (_tmp9_, PANGO_ELLIPSIZE_END);
	_tmp10_ = self->label;
	gtk_label_set_width_chars (_tmp10_, FACES_TOOL_FACE_LABEL_MAX_CHARS);
	_tmp11_ = self->label;
	gtk_box_pack_start (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_widget_get_type (), GtkWidget), TRUE, TRUE, (guint) 0);
	_tmp12_ = self->edit_button;
	gtk_box_pack_start (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
	_tmp13_ = self->delete_button;
	gtk_box_pack_start (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
	self->face_shape = face_shape;
	face_shape_set_widget (face_shape, self);
	return self;
}

FacesToolFaceWidget*
faces_tool_face_widget_new (FaceShape* face_shape)
{
	return faces_tool_face_widget_construct (FACES_TOOL_TYPE_FACE_WIDGET, face_shape);
}

gboolean
faces_tool_face_widget_on_enter_notify_event (FacesToolFaceWidget* self)
{
	FaceShape* _tmp0_;
	FaceShape* _tmp1_;
	gboolean result;
	g_return_val_if_fail (FACES_TOOL_IS_FACE_WIDGET (self), FALSE);
	faces_tool_face_widget_activate_label (self);
	_tmp0_ = self->face_shape;
	if (face_shape_is_editable (_tmp0_)) {
		result = FALSE;
		return result;
	}
	_tmp1_ = self->face_shape;
	if (!face_shape_is_visible (_tmp1_)) {
		FaceShape* _tmp2_;
		_tmp2_ = self->face_shape;
		face_shape_show (_tmp2_);
	}
	result = TRUE;
	return result;
}

gboolean
faces_tool_face_widget_on_leave_notify_event (FacesToolFaceWidget* self)
{
	GdkWindow* _tmp0_;
	gboolean result;
	g_return_val_if_fail (FACES_TOOL_IS_FACE_WIDGET (self), FALSE);
	_tmp0_ = gtk_widget_get_window (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	if (!is_pointer_over (_tmp0_)) {
		FaceShape* _tmp1_;
		FaceShape* _tmp2_;
		faces_tool_face_widget_deactivate_label (self);
		_tmp1_ = self->face_shape;
		if (face_shape_is_editable (_tmp1_)) {
			result = FALSE;
			return result;
		}
		_tmp2_ = self->face_shape;
		face_shape_hide (_tmp2_);
		g_signal_emit (self, faces_tool_face_widget_signals[FACES_TOOL_FACE_WIDGET_FACE_HIDDEN_SIGNAL], 0);
	}
	result = TRUE;
	return result;
}

void
faces_tool_face_widget_activate_label (FacesToolFaceWidget* self)
{
	GtkLabel* _tmp0_;
	PangoAttrList* _tmp1_;
	g_return_if_fail (FACES_TOOL_IS_FACE_WIDGET (self));
	_tmp0_ = self->label;
	_tmp1_ = faces_tool_face_widget_attrs_bold;
	gtk_label_set_attributes (_tmp0_, _tmp1_);
}

void
faces_tool_face_widget_deactivate_label (FacesToolFaceWidget* self)
{
	GtkLabel* _tmp0_;
	PangoAttrList* _tmp1_;
	g_return_if_fail (FACES_TOOL_IS_FACE_WIDGET (self));
	_tmp0_ = self->label;
	_tmp1_ = faces_tool_face_widget_attrs_normal;
	gtk_label_set_attributes (_tmp0_, _tmp1_);
}

static void
faces_tool_face_widget_class_init (FacesToolFaceWidgetClass * klass,
                                   gpointer klass_data)
{
	PangoAttrList* _tmp0_;
	PangoAttrList* _tmp1_;
	PangoAttribute* _tmp2_;
	PangoAttrList* _tmp3_;
	PangoAttrList* _tmp4_;
	PangoAttribute* _tmp5_;
	faces_tool_face_widget_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = faces_tool_face_widget_finalize;
	faces_tool_face_widget_signals[FACES_TOOL_FACE_WIDGET_FACE_HIDDEN_SIGNAL] = g_signal_new ("face-hidden", FACES_TOOL_TYPE_FACE_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	_tmp0_ = pango_attr_list_new ();
	_pango_attr_list_unref0 (faces_tool_face_widget_attrs_bold);
	faces_tool_face_widget_attrs_bold = _tmp0_;
	_tmp1_ = faces_tool_face_widget_attrs_bold;
	_tmp2_ = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
	pango_attr_list_insert (_tmp1_, _tmp2_);
	_tmp3_ = pango_attr_list_new ();
	_pango_attr_list_unref0 (faces_tool_face_widget_attrs_normal);
	faces_tool_face_widget_attrs_normal = _tmp3_;
	_tmp4_ = faces_tool_face_widget_attrs_normal;
	_tmp5_ = pango_attr_weight_new (PANGO_WEIGHT_NORMAL);
	pango_attr_list_insert (_tmp4_, _tmp5_);
}

static void
faces_tool_face_widget_instance_init (FacesToolFaceWidget * self,
                                      gpointer klass)
{
}

static void
faces_tool_face_widget_finalize (GObject * obj)
{
	FacesToolFaceWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FACES_TOOL_TYPE_FACE_WIDGET, FacesToolFaceWidget);
	_g_object_unref0 (self->edit_button);
	_g_object_unref0 (self->delete_button);
	_g_object_unref0 (self->label);
	G_OBJECT_CLASS (faces_tool_face_widget_parent_class)->finalize (obj);
}

static GType
faces_tool_face_widget_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FacesToolFaceWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) faces_tool_face_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FacesToolFaceWidget), 0, (GInstanceInitFunc) faces_tool_face_widget_instance_init, NULL };
	GType faces_tool_face_widget_type_id;
	faces_tool_face_widget_type_id = g_type_register_static (gtk_box_get_type (), "FacesToolFaceWidget", &g_define_type_info, 0);
	return faces_tool_face_widget_type_id;
}

GType
faces_tool_face_widget_get_type (void)
{
	static volatile gsize faces_tool_face_widget_type_id__once = 0;
	if (g_once_init_enter (&faces_tool_face_widget_type_id__once)) {
		GType faces_tool_face_widget_type_id;
		faces_tool_face_widget_type_id = faces_tool_face_widget_get_type_once ();
		g_once_init_leave (&faces_tool_face_widget_type_id__once, faces_tool_face_widget_type_id);
	}
	return faces_tool_face_widget_type_id__once;
}

static inline gpointer
faces_tool_faces_tool_window_get_instance_private (FacesToolFacesToolWindow* self)
{
	return G_STRUCT_MEMBER_P (self, FacesToolFacesToolWindow_private_offset);
}

static void
_faces_tool_faces_tool_window_on_cancel_detection_gtk_button_clicked (GtkButton* _sender,
                                                                      gpointer self)
{
	faces_tool_faces_tool_window_on_cancel_detection ((FacesToolFacesToolWindow*) self);
}

static FacesToolFacesToolWindow*
faces_tool_faces_tool_window_construct (GType object_type,
                                        GtkWindow* container)
{
	FacesToolFacesToolWindow * self = NULL;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	GtkButton* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	GtkButton* _tmp9_;
	GtkButton* _tmp10_;
	GtkButton* _tmp11_;
	GtkButton* _tmp12_;
	GtkBox* _tmp13_;
	GtkLabel* _tmp14_;
	GtkBox* _tmp15_;
	GtkBox* _tmp16_;
	GtkLabel* _tmp17_;
	GtkBox* _tmp18_;
	GtkBox* _tmp19_;
	GtkButton* _tmp20_;
	GtkBox* _tmp21_;
	GtkButton* _tmp22_;
	GtkBox* _tmp23_;
	GtkBox* _tmp24_;
	GtkBox* _tmp25_;
	GtkBox* _tmp26_;
	GtkBox* _tmp27_;
	GtkBox* _tmp28_;
	GtkSeparator* _tmp29_;
	GtkSeparator* _tmp30_;
	GtkBox* _tmp31_;
	GtkBox* _tmp32_;
	GtkBox* _tmp33_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (container, gtk_window_get_type ()), NULL);
	self = (FacesToolFacesToolWindow*) editing_tools_editing_tool_window_construct (object_type, container);
	_tmp0_ = (GtkButton*) gtk_button_new_with_label (RESOURCES_OK_LABEL);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->ok_button);
	self->ok_button = _tmp0_;
	_tmp1_ = self->ok_button;
	gtk_button_set_use_underline (_tmp1_, TRUE);
	_tmp2_ = (GtkButton*) gtk_button_new_with_label (RESOURCES_CANCEL_LABEL);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->cancel_button);
	self->cancel_button = _tmp2_;
	_tmp3_ = self->cancel_button;
	gtk_button_set_use_underline (_tmp3_, TRUE);
	_tmp4_ = (GtkButton*) gtk_button_new_with_label (RESOURCES_CANCEL_LABEL);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->cancel_detection_button);
	self->cancel_detection_button = _tmp4_;
	_tmp5_ = self->cancel_detection_button;
	gtk_button_set_use_underline (_tmp5_, TRUE);
	_tmp6_ = self->detection_button;
	gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_widget_get_type (), GtkWidget), _ ("Detect faces on this photo"));
	_tmp7_ = self->cancel_detection_button;
	gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget), _ ("Cancel face detection"));
	_tmp8_ = self->cancel_detection_button;
	gtk_button_set_image_position (_tmp8_, GTK_POS_LEFT);
	_tmp9_ = self->cancel_detection_button;
	g_signal_connect_object (_tmp9_, "clicked", (GCallback) _faces_tool_faces_tool_window_on_cancel_detection_gtk_button_clicked, self, 0);
	_tmp10_ = self->cancel_button;
	gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_widget_get_type (), GtkWidget), _ ("Close the Faces tool without saving changes"));
	_tmp11_ = self->cancel_button;
	gtk_button_set_image_position (_tmp11_, GTK_POS_LEFT);
	_tmp12_ = self->ok_button;
	gtk_button_set_image_position (_tmp12_, GTK_POS_LEFT);
	_tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, FACES_TOOL_CONTROL_SPACING);
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->face_widgets_layout);
	self->priv->face_widgets_layout = _tmp13_;
	_tmp14_ = (GtkLabel*) gtk_label_new (_ ("Click and drag to tag a face"));
	g_object_ref_sink (_tmp14_);
	_g_object_unref0 (self->priv->help_text);
	self->priv->help_text = _tmp14_;
	_tmp15_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FACES_TOOL_CONTROL_SPACING);
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->help_layout);
	self->priv->help_layout = _tmp15_;
	_tmp16_ = self->priv->help_layout;
	_tmp17_ = self->priv->help_text;
	gtk_box_pack_start (_tmp16_, G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, gtk_widget_get_type (), GtkWidget), TRUE, TRUE, (guint) 0);
	_tmp18_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FACES_TOOL_CONTROL_SPACING);
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->response_layout);
	self->priv->response_layout = _tmp18_;
	_tmp19_ = self->priv->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->priv->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_VERTICAL, FACES_TOOL_CONTROL_SPACING);
	g_object_ref_sink (_tmp23_);
	_g_object_unref0 (self->priv->layout);
	self->priv->layout = _tmp23_;
	_tmp24_ = self->priv->layout;
	_tmp25_ = self->priv->face_widgets_layout;
	gtk_box_pack_start (_tmp24_, G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
	_tmp26_ = self->priv->layout;
	_tmp27_ = self->priv->help_layout;
	gtk_box_pack_start (_tmp26_, G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
	_tmp28_ = self->priv->layout;
	_tmp29_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp29_);
	_tmp30_ = _tmp29_;
	gtk_box_pack_start (_tmp28_, G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
	_g_object_unref0 (_tmp30_);
	_tmp31_ = self->priv->layout;
	_tmp32_ = self->priv->response_layout;
	gtk_box_pack_start (_tmp31_, G_TYPE_CHECK_INSTANCE_CAST (_tmp32_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
	_tmp33_ = self->priv->layout;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp33_, gtk_widget_get_type (), GtkWidget));
	return self;
}

static FacesToolFacesToolWindow*
faces_tool_faces_tool_window_new (GtkWindow* container)
{
	return faces_tool_faces_tool_window_construct (FACES_TOOL_TYPE_FACES_TOOL_WINDOW, container);
}

static void
faces_tool_faces_tool_window_set_editing_phase (FacesToolFacesToolWindow* self,
                                                FacesToolEditingPhase phase,
                                                FaceShape* face_shape)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp19_ = FALSE;
	g_return_if_fail (FACES_TOOL_IS_FACES_TOOL_WINDOW (self));
	g_return_if_fail ((face_shape == NULL) || IS_FACE_SHAPE (face_shape));
	if (self->priv->editing_phase == FACES_TOOL_EDITING_PHASE_DETECTING_FACES) {
		_tmp0_ = phase != FACES_TOOL_EDITING_PHASE_DETECTING_FACES_FINISHED;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	switch (phase) {
		case FACES_TOOL_EDITING_PHASE_CLICK_TO_EDIT:
		{
			GtkLabel* _tmp1_;
			gchar* _tmp2_;
			gchar* _tmp3_;
			gchar* _tmp4_;
			gchar* _tmp5_;
			_vala_assert (face_shape != NULL, "face_shape != null");
			_tmp1_ = self->priv->help_text;
			_tmp2_ = face_shape_get_name (face_shape);
			_tmp3_ = _tmp2_;
			_tmp4_ = g_markup_printf_escaped (_ ("Click to edit face “%s”"), _tmp3_);
			_tmp5_ = _tmp4_;
			gtk_label_set_markup (_tmp1_, _tmp5_);
			_g_free0 (_tmp5_);
			_g_free0 (_tmp3_);
			break;
		}
		case FACES_TOOL_EDITING_PHASE_NOT_EDITING:
		{
			GtkLabel* _tmp6_;
			_tmp6_ = self->priv->help_text;
			gtk_label_set_text (_tmp6_, _ ("Click and drag to tag a face"));
			break;
		}
		case FACES_TOOL_EDITING_PHASE_CREATING_DRAGGING:
		{
			GtkLabel* _tmp7_;
			_tmp7_ = self->priv->help_text;
			gtk_label_set_text (_tmp7_, _ ("Stop dragging to add your face and name it."));
			break;
		}
		case FACES_TOOL_EDITING_PHASE_CREATING_EDITING:
		{
			GtkLabel* _tmp8_;
			_tmp8_ = self->priv->help_text;
			gtk_label_set_text (_tmp8_, _ ("Type a name for this face, then press Enter"));
			break;
		}
		case FACES_TOOL_EDITING_PHASE_EDITING:
		{
			GtkLabel* _tmp9_;
			_tmp9_ = self->priv->help_text;
			gtk_label_set_text (_tmp9_, _ ("Move or modify the face shape or name and press Enter"));
			break;
		}
		case FACES_TOOL_EDITING_PHASE_DETECTING_FACES:
		{
			GtkLabel* _tmp10_;
			GtkButton* _tmp11_;
			GtkContainer* _tmp12_;
			GtkButton* _tmp15_;
			GtkButton* _tmp16_;
			GtkButton* _tmp17_;
			_tmp10_ = self->priv->help_text;
			gtk_label_set_text (_tmp10_, _ ("Detecting faces"));
			_tmp11_ = self->cancel_detection_button;
			_tmp12_ = gtk_widget_get_parent (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_widget_get_type (), GtkWidget));
			if (_tmp12_ == NULL) {
				GtkBox* _tmp13_;
				GtkButton* _tmp14_;
				_tmp13_ = self->priv->help_layout;
				_tmp14_ = self->cancel_detection_button;
				gtk_box_pack_start (_tmp13_, G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
			}
			_tmp15_ = self->detection_button;
			gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_widget_get_type (), GtkWidget), FALSE);
			_tmp16_ = self->cancel_detection_button;
			gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_widget_get_type (), GtkWidget), TRUE);
			_tmp17_ = self->cancel_detection_button;
			gtk_widget_show (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, gtk_widget_get_type (), GtkWidget));
			break;
		}
		case FACES_TOOL_EDITING_PHASE_DETECTING_FACES_FINISHED:
		{
			GtkLabel* _tmp18_;
			_tmp18_ = self->priv->help_text;
			gtk_label_set_text (_tmp18_, _ ("If you don’t set the name of unknown faces they won’t be saved."));
			break;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
	if (self->priv->editing_phase == FACES_TOOL_EDITING_PHASE_DETECTING_FACES) {
		_tmp19_ = self->priv->editing_phase != phase;
	} else {
		_tmp19_ = FALSE;
	}
	if (_tmp19_) {
		GtkButton* _tmp20_;
		GtkButton* _tmp21_;
		_tmp20_ = self->cancel_detection_button;
		gtk_widget_hide (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, gtk_widget_get_type (), GtkWidget));
		_tmp21_ = self->detection_button;
		gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, gtk_widget_get_type (), GtkWidget), TRUE);
	}
	self->priv->editing_phase = phase;
}

static FacesToolEditingPhase
faces_tool_faces_tool_window_get_editing_phase (FacesToolFacesToolWindow* self)
{
	FacesToolEditingPhase result;
	g_return_val_if_fail (FACES_TOOL_IS_FACES_TOOL_WINDOW (self), 0);
	result = self->priv->editing_phase;
	return result;
}

static void
faces_tool_faces_tool_window_ok_button_set_sensitive (FacesToolFacesToolWindow* self,
                                                      gboolean sensitive)
{
	GtkButton* _tmp2_;
	g_return_if_fail (FACES_TOOL_IS_FACES_TOOL_WINDOW (self));
	if (sensitive) {
		GtkButton* _tmp0_;
		_tmp0_ = self->ok_button;
		gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_widget_get_type (), GtkWidget), _ ("Save changes and close the Faces tool"));
	} else {
		GtkButton* _tmp1_;
		_tmp1_ = self->ok_button;
		gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget), _ ("No changes to save"));
	}
	_tmp2_ = self->ok_button;
	gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_widget_get_type (), GtkWidget), sensitive);
}

static void
_faces_tool_faces_tool_window_on_face_hidden_faces_tool_face_widget_face_hidden (FacesToolFaceWidget* _sender,
                                                                                 gpointer self)
{
	faces_tool_faces_tool_window_on_face_hidden ((FacesToolFacesToolWindow*) self);
}

static void
_faces_tool_faces_tool_window_edit_face_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self)
{
	faces_tool_faces_tool_window_edit_face ((FacesToolFacesToolWindow*) self, _sender);
}

static void
_faces_tool_faces_tool_window_delete_face_gtk_button_clicked (GtkButton* _sender,
                                                              gpointer self)
{
	faces_tool_faces_tool_window_delete_face ((FacesToolFacesToolWindow*) self, _sender);
}

static gboolean
_faces_tool_face_widget_on_enter_notify_event_gtk_widget_enter_notify_event (GtkWidget* _sender,
                                                                             GdkEventCrossing* event,
                                                                             gpointer self)
{
	gboolean result;
	result = faces_tool_face_widget_on_enter_notify_event ((FacesToolFaceWidget*) self);
	return result;
}

static gboolean
_faces_tool_face_widget_on_leave_notify_event_gtk_widget_leave_notify_event (GtkWidget* _sender,
                                                                             GdkEventCrossing* event,
                                                                             gpointer self)
{
	gboolean result;
	result = faces_tool_face_widget_on_leave_notify_event ((FacesToolFaceWidget*) self);
	return result;
}

static void
faces_tool_faces_tool_window_add_face (FacesToolFacesToolWindow* self,
                                       FaceShape* face_shape)
{
	FacesToolFaceWidget* face_widget = NULL;
	FacesToolFaceWidget* _tmp0_;
	FacesToolFaceWidget* _tmp1_;
	FacesToolFaceWidget* _tmp2_;
	GtkButton* _tmp3_;
	FacesToolFaceWidget* _tmp4_;
	GtkButton* _tmp5_;
	GtkEventBox* event_box = NULL;
	GtkEventBox* _tmp6_;
	GtkEventBox* _tmp7_;
	FacesToolFaceWidget* _tmp8_;
	GtkEventBox* _tmp9_;
	GtkEventBox* _tmp10_;
	FacesToolFaceWidget* _tmp11_;
	GtkEventBox* _tmp12_;
	FacesToolFaceWidget* _tmp13_;
	GtkBox* _tmp14_;
	GtkEventBox* _tmp15_;
	GtkSeparator* _tmp16_;
	GtkBox* _tmp20_;
	g_return_if_fail (FACES_TOOL_IS_FACES_TOOL_WINDOW (self));
	g_return_if_fail (IS_FACE_SHAPE (face_shape));
	_tmp0_ = faces_tool_face_widget_new (face_shape);
	g_object_ref_sink (_tmp0_);
	face_widget = _tmp0_;
	_tmp1_ = face_widget;
	g_signal_connect_object (_tmp1_, "face-hidden", (GCallback) _faces_tool_faces_tool_window_on_face_hidden_faces_tool_face_widget_face_hidden, self, 0);
	_tmp2_ = face_widget;
	_tmp3_ = _tmp2_->edit_button;
	g_signal_connect_object (_tmp3_, "clicked", (GCallback) _faces_tool_faces_tool_window_edit_face_gtk_button_clicked, self, 0);
	_tmp4_ = face_widget;
	_tmp5_ = _tmp4_->delete_button;
	g_signal_connect_object (_tmp5_, "clicked", (GCallback) _faces_tool_faces_tool_window_delete_face_gtk_button_clicked, self, 0);
	_tmp6_ = (GtkEventBox*) gtk_event_box_new ();
	g_object_ref_sink (_tmp6_);
	event_box = _tmp6_;
	_tmp7_ = event_box;
	_tmp8_ = face_widget;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_widget_get_type (), GtkWidget));
	_tmp9_ = event_box;
	gtk_widget_add_events (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_widget_get_type (), GtkWidget), (gint) (GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK));
	_tmp10_ = event_box;
	_tmp11_ = face_widget;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_widget_get_type (), GtkWidget), "enter-notify-event", (GCallback) _faces_tool_face_widget_on_enter_notify_event_gtk_widget_enter_notify_event, _tmp11_, 0);
	_tmp12_ = event_box;
	_tmp13_ = face_widget;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget), "leave-notify-event", (GCallback) _faces_tool_face_widget_on_leave_notify_event_gtk_widget_leave_notify_event, _tmp13_, 0);
	_tmp14_ = self->priv->face_widgets_layout;
	_tmp15_ = event_box;
	gtk_box_pack_start (_tmp14_, G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
	_tmp16_ = self->priv->buttons_text_separator;
	if (_tmp16_ == NULL) {
		GtkSeparator* _tmp17_;
		GtkBox* _tmp18_;
		GtkSeparator* _tmp19_;
		_tmp17_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
		g_object_ref_sink (_tmp17_);
		_g_object_unref0 (self->priv->buttons_text_separator);
		self->priv->buttons_text_separator = _tmp17_;
		_tmp18_ = self->priv->face_widgets_layout;
		_tmp19_ = self->priv->buttons_text_separator;
		gtk_box_pack_end (_tmp18_, G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
	}
	_tmp20_ = self->priv->face_widgets_layout;
	gtk_widget_show_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (event_box);
	_g_object_unref0 (face_widget);
}

static void
faces_tool_faces_tool_window_edit_face (FacesToolFacesToolWindow* self,
                                        GtkButton* button)
{
	FacesToolFaceWidget* widget = NULL;
	GtkContainer* _tmp0_;
	FacesToolFaceWidget* _tmp1_;
	GtkLabel* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (FACES_TOOL_IS_FACES_TOOL_WINDOW (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (button, gtk_button_get_type ()));
	_tmp0_ = gtk_widget_get_parent (G_TYPE_CHECK_INSTANCE_CAST (button, gtk_widget_get_type (), GtkWidget));
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, FACES_TOOL_TYPE_FACE_WIDGET, FacesToolFaceWidget));
	widget = _tmp1_;
	_tmp2_ = widget->label;
	_tmp3_ = gtk_label_get_text (_tmp2_);
	g_signal_emit (self, faces_tool_faces_tool_window_signals[FACES_TOOL_FACES_TOOL_WINDOW_FACE_EDIT_REQUESTED_SIGNAL], 0, _tmp3_);
	_g_object_unref0 (widget);
}

static void
faces_tool_faces_tool_window_delete_face (FacesToolFacesToolWindow* self,
                                          GtkButton* button)
{
	FacesToolFaceWidget* widget = NULL;
	GtkContainer* _tmp0_;
	FacesToolFaceWidget* _tmp1_;
	FacesToolFaceWidget* _tmp2_;
	GtkLabel* _tmp3_;
	const gchar* _tmp4_;
	FacesToolFaceWidget* _tmp5_;
	GtkContainer* _tmp6_;
	GtkBox* _tmp7_;
	GList* _tmp8_;
	GList* _tmp9_;
	gboolean _tmp10_;
	g_return_if_fail (FACES_TOOL_IS_FACES_TOOL_WINDOW (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (button, gtk_button_get_type ()));
	_tmp0_ = gtk_widget_get_parent (G_TYPE_CHECK_INSTANCE_CAST (button, gtk_widget_get_type (), GtkWidget));
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, FACES_TOOL_TYPE_FACE_WIDGET, FacesToolFaceWidget));
	widget = _tmp1_;
	_tmp2_ = widget;
	_tmp3_ = _tmp2_->label;
	_tmp4_ = gtk_label_get_text (_tmp3_);
	g_signal_emit (self, faces_tool_faces_tool_window_signals[FACES_TOOL_FACES_TOOL_WINDOW_FACE_DELETE_REQUESTED_SIGNAL], 0, _tmp4_);
	_tmp5_ = widget;
	_tmp6_ = gtk_widget_get_parent (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_widget_get_type (), GtkWidget));
	gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_widget_get_type (), GtkWidget));
	_tmp7_ = self->priv->face_widgets_layout;
	_tmp8_ = gtk_container_get_children (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_container_get_type (), GtkContainer));
	_tmp9_ = _tmp8_;
	_tmp10_ = g_list_length (_tmp9_) == ((guint) 1);
	(_tmp9_ == NULL) ? NULL : (_tmp9_ = (g_list_free (_tmp9_), NULL));
	if (_tmp10_) {
		GtkSeparator* _tmp11_;
		_tmp11_ = self->priv->buttons_text_separator;
		gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_widget_get_type (), GtkWidget));
		_g_object_unref0 (self->priv->buttons_text_separator);
		self->priv->buttons_text_separator = NULL;
	}
	_g_object_unref0 (widget);
}

static void
faces_tool_faces_tool_window_on_face_hidden (FacesToolFacesToolWindow* self)
{
	g_return_if_fail (FACES_TOOL_IS_FACES_TOOL_WINDOW (self));
	g_signal_emit (self, faces_tool_faces_tool_window_signals[FACES_TOOL_FACES_TOOL_WINDOW_FACE_HIDDEN_SIGNAL], 0);
}

static void
faces_tool_faces_tool_window_on_cancel_detection (FacesToolFacesToolWindow* self)
{
	g_return_if_fail (FACES_TOOL_IS_FACES_TOOL_WINDOW (self));
	g_signal_emit (self, faces_tool_faces_tool_window_signals[FACES_TOOL_FACES_TOOL_WINDOW_DETECTION_CANCELED_SIGNAL], 0);
}

static void
faces_tool_faces_tool_window_class_init (FacesToolFacesToolWindowClass * klass,
                                         gpointer klass_data)
{
	faces_tool_faces_tool_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FacesToolFacesToolWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = faces_tool_faces_tool_window_finalize;
	faces_tool_faces_tool_window_signals[FACES_TOOL_FACES_TOOL_WINDOW_FACE_HIDDEN_SIGNAL] = g_signal_new ("face-hidden", FACES_TOOL_TYPE_FACES_TOOL_WINDOW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	faces_tool_faces_tool_window_signals[FACES_TOOL_FACES_TOOL_WINDOW_FACE_EDIT_REQUESTED_SIGNAL] = g_signal_new ("face-edit-requested", FACES_TOOL_TYPE_FACES_TOOL_WINDOW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	faces_tool_faces_tool_window_signals[FACES_TOOL_FACES_TOOL_WINDOW_FACE_DELETE_REQUESTED_SIGNAL] = g_signal_new ("face-delete-requested", FACES_TOOL_TYPE_FACES_TOOL_WINDOW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	faces_tool_faces_tool_window_signals[FACES_TOOL_FACES_TOOL_WINDOW_DETECTION_CANCELED_SIGNAL] = g_signal_new ("detection-canceled", FACES_TOOL_TYPE_FACES_TOOL_WINDOW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
faces_tool_faces_tool_window_instance_init (FacesToolFacesToolWindow * self,
                                            gpointer klass)
{
	GtkButton* _tmp0_;
	self->priv = faces_tool_faces_tool_window_get_instance_private (self);
	_tmp0_ = (GtkButton*) gtk_button_new_with_label (_ ("Detect faces…"));
	g_object_ref_sink (_tmp0_);
	self->detection_button = _tmp0_;
	self->priv->editing_phase = FACES_TOOL_EDITING_PHASE_NOT_EDITING;
	self->priv->help_layout = NULL;
	self->priv->response_layout = NULL;
	self->priv->buttons_text_separator = NULL;
	self->priv->help_text = NULL;
	self->priv->face_widgets_layout = NULL;
	self->priv->layout = NULL;
}

static void
faces_tool_faces_tool_window_finalize (GObject * obj)
{
	FacesToolFacesToolWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FACES_TOOL_TYPE_FACES_TOOL_WINDOW, FacesToolFacesToolWindow);
	_g_object_unref0 (self->detection_button);
	_g_object_unref0 (self->ok_button);
	_g_object_unref0 (self->cancel_button);
	_g_object_unref0 (self->cancel_detection_button);
	_g_object_unref0 (self->priv->help_layout);
	_g_object_unref0 (self->priv->response_layout);
	_g_object_unref0 (self->priv->buttons_text_separator);
	_g_object_unref0 (self->priv->help_text);
	_g_object_unref0 (self->priv->face_widgets_layout);
	_g_object_unref0 (self->priv->layout);
	G_OBJECT_CLASS (faces_tool_faces_tool_window_parent_class)->finalize (obj);
}

static GType
faces_tool_faces_tool_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FacesToolFacesToolWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) faces_tool_faces_tool_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FacesToolFacesToolWindow), 0, (GInstanceInitFunc) faces_tool_faces_tool_window_instance_init, NULL };
	GType faces_tool_faces_tool_window_type_id;
	faces_tool_faces_tool_window_type_id = g_type_register_static (EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, "FacesToolFacesToolWindow", &g_define_type_info, 0);
	FacesToolFacesToolWindow_private_offset = g_type_add_instance_private (faces_tool_faces_tool_window_type_id, sizeof (FacesToolFacesToolWindowPrivate));
	return faces_tool_faces_tool_window_type_id;
}

static GType
faces_tool_faces_tool_window_get_type (void)
{
	static volatile gsize faces_tool_faces_tool_window_type_id__once = 0;
	if (g_once_init_enter (&faces_tool_faces_tool_window_type_id__once)) {
		GType faces_tool_faces_tool_window_type_id;
		faces_tool_faces_tool_window_type_id = faces_tool_faces_tool_window_get_type_once ();
		g_once_init_leave (&faces_tool_faces_tool_window_type_id__once, faces_tool_faces_tool_window_type_id);
	}
	return faces_tool_faces_tool_window_type_id__once;
}

static inline gpointer
faces_tool_editing_face_tool_window_get_instance_private (FacesToolEditingFaceToolWindow* self)
{
	return G_STRUCT_MEMBER_P (self, FacesToolEditingFaceToolWindow_private_offset);
}

FacesToolEditingFaceToolWindow*
faces_tool_editing_face_tool_window_construct (GType object_type,
                                               GtkWindow* container)
{
	FacesToolEditingFaceToolWindow * self = NULL;
	GtkEntry* _tmp0_;
	GtkBox* _tmp1_;
	GtkBox* _tmp2_;
	GtkEntry* _tmp3_;
	GtkBox* _tmp4_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (container, gtk_window_get_type ()), NULL);
	self = (FacesToolEditingFaceToolWindow*) editing_tools_editing_tool_window_construct (object_type, container);
	_tmp0_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->entry);
	self->entry = _tmp0_;
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FACES_TOOL_CONTROL_SPACING);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->layout);
	self->priv->layout = _tmp1_;
	_tmp2_ = self->priv->layout;
	_tmp3_ = self->entry;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget));
	_tmp4_ = self->priv->layout;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_widget_get_type (), GtkWidget));
	return self;
}

FacesToolEditingFaceToolWindow*
faces_tool_editing_face_tool_window_new (GtkWindow* container)
{
	return faces_tool_editing_face_tool_window_construct (FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW, container);
}

static gboolean
faces_tool_editing_face_tool_window_real_key_press_event (GtkWidget* base,
                                                          GdkEventKey* event)
{
	FacesToolEditingFaceToolWindow * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW, FacesToolEditingFaceToolWindow);
	g_return_val_if_fail (event != NULL, FALSE);
	g_signal_emit (self, faces_tool_editing_face_tool_window_signals[FACES_TOOL_EDITING_FACE_TOOL_WINDOW_KEY_PRESSED_SIGNAL], 0, event, &_tmp1_);
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = GTK_WIDGET_CLASS (faces_tool_editing_face_tool_window_parent_class)->key_press_event (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, EditingToolsEditingToolWindow), gtk_widget_get_type (), GtkWidget), event);
	}
	result = _tmp0_;
	return result;
}

static void
g_cclosure_user_marshal_BOOLEAN__BOXED (GClosure * closure,
                                        GValue * return_value,
                                        guint n_param_values,
                                        const GValue * param_values,
                                        gpointer invocation_hint,
                                        gpointer marshal_data)
{
	typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED) (gpointer data1, gpointer arg_1, gpointer data2);
	register GMarshalFunc_BOOLEAN__BOXED callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	gboolean v_return;
	cc = (GCClosure *) closure;
	g_return_if_fail (return_value != NULL);
	g_return_if_fail (n_param_values == 2);
	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_BOOLEAN__BOXED) (marshal_data ? marshal_data : cc->callback);
	v_return = callback (data1, g_value_get_boxed (param_values + 1), data2);
	g_value_set_boolean (return_value, v_return);
}

static void
faces_tool_editing_face_tool_window_class_init (FacesToolEditingFaceToolWindowClass * klass,
                                                gpointer klass_data)
{
	faces_tool_editing_face_tool_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FacesToolEditingFaceToolWindow_private_offset);
	((GtkWidgetClass *) klass)->key_press_event = (gboolean (*) (GtkWidget*, GdkEventKey*)) faces_tool_editing_face_tool_window_real_key_press_event;
	G_OBJECT_CLASS (klass)->finalize = faces_tool_editing_face_tool_window_finalize;
	faces_tool_editing_face_tool_window_signals[FACES_TOOL_EDITING_FACE_TOOL_WINDOW_KEY_PRESSED_SIGNAL] = g_signal_new ("key-pressed", FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_BOOLEAN__BOXED, G_TYPE_BOOLEAN, 1, gdk_event_get_type ());
}

static void
faces_tool_editing_face_tool_window_instance_init (FacesToolEditingFaceToolWindow * self,
                                                   gpointer klass)
{
	self->priv = faces_tool_editing_face_tool_window_get_instance_private (self);
	self->priv->layout = NULL;
}

static void
faces_tool_editing_face_tool_window_finalize (GObject * obj)
{
	FacesToolEditingFaceToolWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FACES_TOOL_TYPE_EDITING_FACE_TOOL_WINDOW, FacesToolEditingFaceToolWindow);
	_g_object_unref0 (self->entry);
	_g_object_unref0 (self->priv->layout);
	G_OBJECT_CLASS (faces_tool_editing_face_tool_window_parent_class)->finalize (obj);
}

static GType
faces_tool_editing_face_tool_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FacesToolEditingFaceToolWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) faces_tool_editing_face_tool_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FacesToolEditingFaceToolWindow), 0, (GInstanceInitFunc) faces_tool_editing_face_tool_window_instance_init, NULL };
	GType faces_tool_editing_face_tool_window_type_id;
	faces_tool_editing_face_tool_window_type_id = g_type_register_static (EDITING_TOOLS_TYPE_EDITING_TOOL_WINDOW, "FacesToolEditingFaceToolWindow", &g_define_type_info, 0);
	FacesToolEditingFaceToolWindow_private_offset = g_type_add_instance_private (faces_tool_editing_face_tool_window_type_id, sizeof (FacesToolEditingFaceToolWindowPrivate));
	return faces_tool_editing_face_tool_window_type_id;
}

GType
faces_tool_editing_face_tool_window_get_type (void)
{
	static volatile gsize faces_tool_editing_face_tool_window_type_id__once = 0;
	if (g_once_init_enter (&faces_tool_editing_face_tool_window_type_id__once)) {
		GType faces_tool_editing_face_tool_window_type_id;
		faces_tool_editing_face_tool_window_type_id = faces_tool_editing_face_tool_window_get_type_once ();
		g_once_init_leave (&faces_tool_editing_face_tool_window_type_id__once, faces_tool_editing_face_tool_window_type_id);
	}
	return faces_tool_editing_face_tool_window_type_id__once;
}

static inline gpointer
faces_tool_face_detection_job_get_instance_private (FacesToolFaceDetectionJob* self)
{
	return G_STRUCT_MEMBER_P (self, FacesToolFaceDetectionJob_private_offset);
}

static FacesToolFaceDetectionJob*
faces_tool_face_detection_job_construct (GType object_type,
                                         FacesToolFacesToolWindow* owner,
                                         const gchar* image_path,
                                         gfloat scale,
                                         CompletionCallback completion_callback,
                                         gpointer completion_callback_target,
                                         GCancellable* cancellable,
                                         CancellationCallback cancellation_callback,
                                         gpointer cancellation_callback_target)
{
	FacesToolFaceDetectionJob* self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (FACES_TOOL_IS_FACES_TOOL_WINDOW (owner), NULL);
	g_return_val_if_fail (image_path != NULL, NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()), NULL);
	self = (FacesToolFaceDetectionJob*) background_job_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (owner, G_TYPE_OBJECT, GObject), completion_callback, completion_callback_target, cancellable, cancellation_callback, cancellation_callback_target, NULL);
	_tmp0_ = g_strdup (image_path);
	_g_free0 (self->priv->image_path);
	self->priv->image_path = _tmp0_;
	self->priv->scale = scale;
	return self;
}

static FacesToolFaceDetectionJob*
faces_tool_face_detection_job_new (FacesToolFacesToolWindow* owner,
                                   const gchar* image_path,
                                   gfloat scale,
                                   CompletionCallback completion_callback,
                                   gpointer completion_callback_target,
                                   GCancellable* cancellable,
                                   CancellationCallback cancellation_callback,
                                   gpointer cancellation_callback_target)
{
	return faces_tool_face_detection_job_construct (FACES_TOOL_TYPE_FACE_DETECTION_JOB, owner, image_path, scale, completion_callback, completion_callback_target, cancellable, cancellation_callback, cancellation_callback_target);
}

static void
_vala_FaceRect_array_free (FaceRect * array,
                           gssize array_length)
{
	if (array != NULL) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			face_rect_destroy (&array[i]);
		}
	}
	g_free (array);
}

static gchar*
double_to_string (gdouble self)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint _tmp1__length1;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = G_ASCII_DTOSTR_BUF_SIZE;
	_tmp2_ = g_ascii_dtostr (_tmp1_, (gint) G_ASCII_DTOSTR_BUF_SIZE, self);
	_tmp3_ = g_strdup (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp1_ = (g_free (_tmp1_), NULL);
	result = _tmp4_;
	return result;
}

static void
faces_tool_face_detection_job_real_execute (BackgroundJob* base)
{
	FacesToolFaceDetectionJob * self;
	FaceRect* rects = NULL;
	gint rects_length1 = 0;
	gint _rects_size_ = 0;
	GeePriorityQueue* _tmp17_;
	GError* _inner_error0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, FACES_TOOL_TYPE_FACE_DETECTION_JOB, FacesToolFaceDetectionJob);
	if (!face_detect_connected) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("Face detect process not connected!\n");
		_g_free0 (self->spawnError);
		self->spawnError = _tmp0_;
		return;
	}
	{
		FaceRect* _tmp1_ = NULL;
		FaceDetectInterface* _tmp2_;
		const gchar* _tmp3_;
		GFile* _tmp4_;
		GFile* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		gint _tmp8_ = 0;
		FaceRect* _tmp9_;
		FaceRect* _tmp10_;
		gint _tmp10__length1;
		gint _tmp1__length1;
		gint __tmp1__size_;
		FaceRect* _tmp11_;
		gint _tmp11__length1;
		_tmp2_ = face_detect_face_detect_proxy;
		_tmp3_ = self->priv->image_path;
		_tmp4_ = app_dirs_get_haarcascade_file ();
		_tmp5_ = _tmp4_;
		_tmp6_ = g_file_get_path (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp9_ = face_detect_interface_detect_faces (_tmp2_, _tmp3_, _tmp7_, (gdouble) self->priv->scale, TRUE, &_tmp8_, &_inner_error0_);
		_tmp10_ = _tmp9_;
		_tmp10__length1 = _tmp8_;
		_g_free0 (_tmp7_);
		_g_object_unref0 (_tmp5_);
		_tmp1_ = _tmp10_;
		_tmp1__length1 = _tmp10__length1;
		__tmp1__size_ = _tmp1__length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp11_ = _tmp1_;
		_tmp11__length1 = _tmp1__length1;
		_tmp1_ = NULL;
		_tmp1__length1 = 0;
		rects = (_vala_FaceRect_array_free (rects, rects_length1), NULL);
		rects = _tmp11_;
		rects_length1 = _tmp11__length1;
		_rects_size_ = rects_length1;
		_tmp1_ = (_vala_FaceRect_array_free (_tmp1_, _tmp1__length1), NULL);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp12_ = e;
		_tmp13_ = _tmp12_->message;
		_tmp14_ = g_strconcat ("DBus error: ", _tmp13_, NULL);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_strconcat (_tmp15_, "!\n", NULL);
		_g_free0 (self->spawnError);
		self->spawnError = _tmp16_;
		_g_free0 (_tmp15_);
		_g_error_free0 (e);
		rects = (_vala_FaceRect_array_free (rects, rects_length1), NULL);
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		rects = (_vala_FaceRect_array_free (rects, rects_length1), 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;
	}
	_tmp17_ = gee_priority_queue_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->faces);
	self->priv->faces = G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, GEE_TYPE_QUEUE, GeeQueue);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp18_ = FALSE;
			_tmp18_ = TRUE;
			while (TRUE) {
				FaceRect* _tmp20_;
				gint _tmp20__length1;
				gdouble rect_x = 0.0;
				gdouble rect_y = 0.0;
				gdouble rect_w = 0.0;
				gdouble rect_h = 0.0;
				gchar* face_vec_str = NULL;
				gchar* _tmp21_;
				FaceRect* _tmp22_;
				gint _tmp22__length1;
				FaceRect _tmp23_;
				FaceRect* _tmp24_;
				gint _tmp24__length1;
				FaceRect _tmp25_;
				FaceRect* _tmp26_;
				gint _tmp26__length1;
				FaceRect _tmp27_;
				FaceRect* _tmp28_;
				gint _tmp28__length1;
				FaceRect _tmp29_;
				FaceRect* _tmp30_;
				gint _tmp30__length1;
				FaceRect _tmp31_;
				gdouble* _tmp32_;
				gint _tmp32__length1;
				gchar* serialized = NULL;
				const gchar* _tmp42_;
				gchar* _tmp43_;
				GeeQueue* _tmp44_;
				const gchar* _tmp45_;
				if (!_tmp18_) {
					gint _tmp19_;
					_tmp19_ = i;
					i = _tmp19_ + 1;
				}
				_tmp18_ = FALSE;
				_tmp20_ = rects;
				_tmp20__length1 = rects_length1;
				if (!(i < _tmp20__length1)) {
					break;
				}
				_tmp21_ = g_strdup ("");
				face_vec_str = _tmp21_;
				_tmp22_ = rects;
				_tmp22__length1 = rects_length1;
				_tmp23_ = _tmp22_[i];
				rect_w = _tmp23_.width / 2;
				_tmp24_ = rects;
				_tmp24__length1 = rects_length1;
				_tmp25_ = _tmp24_[i];
				rect_h = _tmp25_.height / 2;
				_tmp26_ = rects;
				_tmp26__length1 = rects_length1;
				_tmp27_ = _tmp26_[i];
				rect_x = _tmp27_.x + rect_w;
				_tmp28_ = rects;
				_tmp28__length1 = rects_length1;
				_tmp29_ = _tmp28_[i];
				rect_y = _tmp29_.y + rect_h;
				_tmp30_ = rects;
				_tmp30__length1 = rects_length1;
				_tmp31_ = _tmp30_[i];
				_tmp32_ = _tmp31_.vec;
				_tmp32__length1 = _tmp31_.vec_length1;
				if (_tmp32_ != NULL) {
					FaceRect* _tmp33_;
					gint _tmp33__length1;
					FaceRect _tmp34_;
					gdouble* _tmp35_;
					gint _tmp35__length1;
					_tmp33_ = rects;
					_tmp33__length1 = rects_length1;
					_tmp34_ = _tmp33_[i];
					_tmp35_ = _tmp34_.vec;
					_tmp35__length1 = _tmp34_.vec_length1;
					{
						gdouble* d_collection = NULL;
						gint d_collection_length1 = 0;
						gint _d_collection_size_ = 0;
						gint d_it = 0;
						d_collection = _tmp35_;
						d_collection_length1 = _tmp35__length1;
						for (d_it = 0; d_it < d_collection_length1; d_it = d_it + 1) {
							gdouble d = 0.0;
							d = d_collection[d_it];
							{
								const gchar* _tmp36_;
								gchar* _tmp37_;
								gchar* _tmp38_;
								gchar* _tmp39_;
								gchar* _tmp40_;
								gchar* _tmp41_;
								_tmp36_ = face_vec_str;
								_tmp37_ = double_to_string (d);
								_tmp38_ = _tmp37_;
								_tmp39_ = g_strconcat (_tmp38_, ",", NULL);
								_tmp40_ = _tmp39_;
								_tmp41_ = g_strconcat (_tmp36_, _tmp40_, NULL);
								_g_free0 (face_vec_str);
								face_vec_str = _tmp41_;
								_g_free0 (_tmp40_);
								_g_free0 (_tmp38_);
							}
						}
					}
				}
				_tmp42_ = face_vec_str;
				_tmp43_ = g_strdup_printf ("%s;%f;%f;%f;%f;%s", FACE_RECTANGLE_SHAPE_TYPE, rect_x, rect_y, rect_w, rect_h, _tmp42_);
				serialized = _tmp43_;
				_tmp44_ = self->priv->faces;
				_tmp45_ = serialized;
				gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp44_, GEE_TYPE_COLLECTION, GeeCollection), _tmp45_);
				_g_free0 (serialized);
				_g_free0 (face_vec_str);
			}
		}
	}
	rects = (_vala_FaceRect_array_free (rects, rects_length1), NULL);
}

static gchar*
faces_tool_face_detection_job_get_next (FacesToolFaceDetectionJob* self)
{
	GeeQueue* _tmp0_;
	GeeQueue* _tmp1_;
	gpointer _tmp2_;
	gchar* result;
	g_return_val_if_fail (FACES_TOOL_IS_FACE_DETECTION_JOB (self), NULL);
	_tmp0_ = self->priv->faces;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->priv->faces;
	_tmp2_ = gee_queue_poll (_tmp1_);
	result = (gchar*) _tmp2_;
	return result;
}

static void
faces_tool_face_detection_job_reset (FacesToolFaceDetectionJob* self)
{
	g_return_if_fail (FACES_TOOL_IS_FACE_DETECTION_JOB (self));
	_g_object_unref0 (self->priv->faces);
	self->priv->faces = NULL;
}

static void
faces_tool_face_detection_job_class_init (FacesToolFaceDetectionJobClass * klass,
                                          gpointer klass_data)
{
	faces_tool_face_detection_job_parent_class = g_type_class_peek_parent (klass);
	((BackgroundJobClass *) klass)->finalize = faces_tool_face_detection_job_finalize;
	g_type_class_adjust_private_offset (klass, &FacesToolFaceDetectionJob_private_offset);
	((BackgroundJobClass *) klass)->execute = (void (*) (BackgroundJob*)) faces_tool_face_detection_job_real_execute;
}

static void
faces_tool_face_detection_job_instance_init (FacesToolFaceDetectionJob * self,
                                             gpointer klass)
{
	self->priv = faces_tool_face_detection_job_get_instance_private (self);
	self->priv->faces = NULL;
}

static void
faces_tool_face_detection_job_finalize (BackgroundJob * obj)
{
	FacesToolFaceDetectionJob * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FACES_TOOL_TYPE_FACE_DETECTION_JOB, FacesToolFaceDetectionJob);
	_g_object_unref0 (self->priv->faces);
	_g_free0 (self->priv->image_path);
	_g_free0 (self->spawnError);
	BACKGROUND_JOB_CLASS (faces_tool_face_detection_job_parent_class)->finalize (obj);
}

static GType
faces_tool_face_detection_job_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FacesToolFaceDetectionJobClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) faces_tool_face_detection_job_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FacesToolFaceDetectionJob), 0, (GInstanceInitFunc) faces_tool_face_detection_job_instance_init, NULL };
	GType faces_tool_face_detection_job_type_id;
	faces_tool_face_detection_job_type_id = g_type_register_static (TYPE_BACKGROUND_JOB, "FacesToolFaceDetectionJob", &g_define_type_info, 0);
	FacesToolFaceDetectionJob_private_offset = g_type_add_instance_private (faces_tool_face_detection_job_type_id, sizeof (FacesToolFaceDetectionJobPrivate));
	return faces_tool_face_detection_job_type_id;
}

static GType
faces_tool_face_detection_job_get_type (void)
{
	static volatile gsize faces_tool_face_detection_job_type_id__once = 0;
	if (g_once_init_enter (&faces_tool_face_detection_job_type_id__once)) {
		GType faces_tool_face_detection_job_type_id;
		faces_tool_face_detection_job_type_id = faces_tool_face_detection_job_get_type_once ();
		g_once_init_leave (&faces_tool_face_detection_job_type_id__once, faces_tool_face_detection_job_type_id);
	}
	return faces_tool_face_detection_job_type_id__once;
}

static void
faces_tool_class_init (FacesToolClass * klass,
                       gpointer klass_data)
{
	faces_tool_parent_class = g_type_class_peek_parent (klass);
	((EditingToolsEditingToolClass *) klass)->finalize = faces_tool_finalize;
	g_type_class_adjust_private_offset (klass, &FacesTool_private_offset);
	((EditingToolsEditingToolClass *) klass)->activate = (void (*) (EditingToolsEditingTool*, EditingToolsPhotoCanvas*)) faces_tool_real_activate;
	((EditingToolsEditingToolClass *) klass)->deactivate = (void (*) (EditingToolsEditingTool*)) faces_tool_real_deactivate;
	((EditingToolsEditingToolClass *) klass)->on_keypress = (gboolean (*) (EditingToolsEditingTool*, GdkEventKey*)) faces_tool_real_on_keypress;
	((EditingToolsEditingToolClass *) klass)->on_left_click = (void (*) (EditingToolsEditingTool*, gint, gint)) faces_tool_real_on_left_click;
	((EditingToolsEditingToolClass *) klass)->on_left_released = (void (*) (EditingToolsEditingTool*, gint, gint)) faces_tool_real_on_left_released;
	((EditingToolsEditingToolClass *) klass)->on_motion = (void (*) (EditingToolsEditingTool*, gint, gint, GdkModifierType)) faces_tool_real_on_motion;
	((EditingToolsEditingToolClass *) klass)->on_leave_notify_event = (gboolean (*) (EditingToolsEditingTool*)) faces_tool_real_on_leave_notify_event;
	((EditingToolsEditingToolClass *) klass)->get_tool_window = (EditingToolsEditingToolWindow* (*) (EditingToolsEditingTool*)) faces_tool_real_get_tool_window;
	((EditingToolsEditingToolClass *) klass)->paint = (void (*) (EditingToolsEditingTool*, cairo_t*)) faces_tool_real_paint;
}

static void
faces_tool_instance_init (FacesTool * self,
                          gpointer klass)
{
	self->priv = faces_tool_get_instance_private (self);
	self->priv->image_surface = NULL;
	self->priv->editing_face_shape = NULL;
	self->priv->faces_tool_window = NULL;
}

static void
faces_tool_finalize (EditingToolsEditingTool * obj)
{
	FacesTool * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FACES_TOOL, FacesTool);
	_cairo_surface_destroy0 (self->priv->image_surface);
	_g_object_unref0 (self->priv->face_shapes);
	_g_object_unref0 (self->priv->original_face_locations);
	_g_object_unref0 (self->priv->face_detection_cancellable);
	_background_job_unref0 (self->priv->face_detection);
	_workers_unref0 (self->priv->workers);
	_g_object_unref0 (self->priv->editing_face_shape);
	_g_object_unref0 (self->priv->faces_tool_window);
	EDITING_TOOLS_EDITING_TOOL_CLASS (faces_tool_parent_class)->finalize (obj);
}

static GType
faces_tool_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FacesToolClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) faces_tool_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FacesTool), 0, (GInstanceInitFunc) faces_tool_instance_init, NULL };
	GType faces_tool_type_id;
	faces_tool_type_id = g_type_register_static (EDITING_TOOLS_TYPE_EDITING_TOOL, "FacesTool", &g_define_type_info, 0);
	FacesTool_private_offset = g_type_add_instance_private (faces_tool_type_id, sizeof (FacesToolPrivate));
	return faces_tool_type_id;
}

GType
faces_tool_get_type (void)
{
	static volatile gsize faces_tool_type_id__once = 0;
	if (g_once_init_enter (&faces_tool_type_id__once)) {
		GType faces_tool_type_id;
		faces_tool_type_id = faces_tool_get_type_once ();
		g_once_init_leave (&faces_tool_type_id__once, faces_tool_type_id);
	}
	return faces_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);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

