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

/*
* Copyright (c) 2018-2026 (https://github.com/phase1geo/Minder)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Trevor Williams <phase1geo@gmail.com>
*/

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

#define IMAGE_EDITOR_MIN_WIDTH ((gdouble) 50)
#define IMAGE_EDITOR_CROP_WIDTH 8
#define IMAGE_EDITOR_EDIT_WIDTH 600
#define IMAGE_EDITOR_EDIT_HEIGHT 600
#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_IMAGE_EDITOR (image_editor_get_type ())
#define IMAGE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IMAGE_EDITOR, ImageEditor))
#define IMAGE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_IMAGE_EDITOR, ImageEditorClass))
#define IS_IMAGE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IMAGE_EDITOR))
#define IS_IMAGE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_IMAGE_EDITOR))
#define IMAGE_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_IMAGE_EDITOR, ImageEditorClass))

typedef struct _ImageEditor ImageEditor;
typedef struct _ImageEditorClass ImageEditorClass;
typedef struct _ImageEditorPrivate ImageEditorPrivate;

#define TYPE_IMAGE_MANAGER (image_manager_get_type ())
#define IMAGE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IMAGE_MANAGER, ImageManager))
#define IMAGE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_IMAGE_MANAGER, ImageManagerClass))
#define IS_IMAGE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IMAGE_MANAGER))
#define IS_IMAGE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_IMAGE_MANAGER))
#define IMAGE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_IMAGE_MANAGER, ImageManagerClass))

typedef struct _ImageManager ImageManager;
typedef struct _ImageManagerClass ImageManagerClass;

#define TYPE_NODE (node_get_type ())
#define NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE, Node))
#define NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE, NodeClass))
#define IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE))
#define IS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE))
#define NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE, NodeClass))

typedef struct _Node Node;
typedef struct _NodeClass NodeClass;

#define TYPE_NODE_IMAGE (node_image_get_type ())
#define NODE_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE_IMAGE, NodeImage))
#define NODE_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE_IMAGE, NodeImageClass))
#define IS_NODE_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE_IMAGE))
#define IS_NODE_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE_IMAGE))
#define NODE_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE_IMAGE, NodeImageClass))

typedef struct _NodeImage NodeImage;
typedef struct _NodeImageClass NodeImageClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _image_manager_unref0(var) ((var == NULL) ? NULL : (var = (image_manager_unref (var), NULL)))
#define _node_image_unref0(var) ((var == NULL) ? NULL : (var = (node_image_unref (var), NULL)))

#define TYPE_DRAW_AREA (draw_area_get_type ())
#define DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DRAW_AREA, DrawArea))
#define DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DRAW_AREA, DrawAreaClass))
#define IS_DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DRAW_AREA))
#define IS_DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DRAW_AREA))
#define DRAW_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DRAW_AREA, DrawAreaClass))

typedef struct _DrawArea DrawArea;
typedef struct _DrawAreaClass DrawAreaClass;

#define TYPE_MIND_MAP (mind_map_get_type ())
#define MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MIND_MAP, MindMap))
#define MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MIND_MAP, MindMapClass))
#define IS_MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MIND_MAP))
#define IS_MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MIND_MAP))
#define MIND_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MIND_MAP, MindMapClass))

typedef struct _MindMap MindMap;
typedef struct _MindMapClass MindMapClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_STYLE (style_get_type ())
#define STYLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_STYLE, Style))
#define STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_STYLE, StyleClass))
#define IS_STYLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_STYLE))
#define IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_STYLE))
#define STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_STYLE, StyleClass))

typedef struct _Style Style;
typedef struct _StyleClass StyleClass;
typedef struct _Block23Data Block23Data;
#define _image_editor_unref0(var) ((var == NULL) ? NULL : (var = (image_editor_unref (var), NULL)))
typedef struct _Block24Data Block24Data;
typedef void (*ImageIdFunc) (gint id, gpointer user_data);

#define TYPE_MAIN_WINDOW (main_window_get_type ())
#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))

typedef struct _MainWindow MainWindow;
typedef struct _MainWindowClass MainWindowClass;
typedef struct _Block25Data Block25Data;
typedef struct _ParamSpecImageEditor ParamSpecImageEditor;
enum  {
	IMAGE_EDITOR_CHANGED_SIGNAL,
	IMAGE_EDITOR_NUM_SIGNALS
};
static guint image_editor_signals[IMAGE_EDITOR_NUM_SIGNALS] = {0};

struct _ImageEditor {
	GTypeInstance parent_instance;
	volatile int ref_count;
	ImageEditorPrivate * priv;
};

struct _ImageEditorClass {
	GTypeClass parent_class;
	void (*finalize) (ImageEditor *self);
};

struct _ImageEditorPrivate {
	GtkPopover* _popover;
	ImageManager* _im;
	GtkDrawingArea* _da;
	Node* _node;
	NodeImage* _image;
	GtkButton* _paste;
	gint _crop_target;
	gdouble _press_x;
	gdouble _press_y;
	GdkRectangle* _crop_points;
	gint _crop_points_length1;
	gint __crop_points_size_;
	gchar** _crop_cursors;
	gint _crop_cursors_length1;
	gint __crop_cursors_size_;
	GtkLabel* _status_cursor;
	GtkLabel* _status_crop;
	gdouble _scale;
	gdouble _crop_x;
	gdouble _crop_y;
	gdouble _crop_w;
	gdouble _crop_h;
};

struct _Block23Data {
	int _ref_count_;
	ImageEditor* self;
	GtkDrawingArea* da;
	ImageManager* im;
};

struct _Block24Data {
	int _ref_count_;
	ImageEditor* self;
	DrawArea* da;
	ImageManager* im;
};

struct _Block25Data {
	int _ref_count_;
	ImageEditor* self;
	GdkClipboard* clipboard;
};

struct _ParamSpecImageEditor {
	GParamSpec parent_instance;
};

static gint ImageEditor_private_offset;
static gpointer image_editor_parent_class = NULL;

VALA_EXTERN gpointer image_editor_ref (gpointer instance);
VALA_EXTERN void image_editor_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_image_editor (const gchar* name,
                                     const gchar* nick,
                                     const gchar* blurb,
                                     GType object_type,
                                     GParamFlags flags);
VALA_EXTERN void value_set_image_editor (GValue* value,
                             gpointer v_object);
VALA_EXTERN void value_take_image_editor (GValue* value,
                              gpointer v_object);
VALA_EXTERN gpointer value_get_image_editor (const GValue* value);
VALA_EXTERN GType image_editor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ImageEditor, image_editor_unref)
VALA_EXTERN gpointer image_manager_ref (gpointer instance);
VALA_EXTERN void image_manager_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_image_manager (const gchar* name,
                                      const gchar* nick,
                                      const gchar* blurb,
                                      GType object_type,
                                      GParamFlags flags);
VALA_EXTERN void value_set_image_manager (GValue* value,
                              gpointer v_object);
VALA_EXTERN void value_take_image_manager (GValue* value,
                               gpointer v_object);
VALA_EXTERN gpointer value_get_image_manager (const GValue* value);
VALA_EXTERN GType image_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ImageManager, image_manager_unref)
VALA_EXTERN GType node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Node, g_object_unref)
VALA_EXTERN gpointer node_image_ref (gpointer instance);
VALA_EXTERN void node_image_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_node_image (const gchar* name,
                                   const gchar* nick,
                                   const gchar* blurb,
                                   GType object_type,
                                   GParamFlags flags);
VALA_EXTERN void value_set_node_image (GValue* value,
                           gpointer v_object);
VALA_EXTERN void value_take_node_image (GValue* value,
                            gpointer v_object);
VALA_EXTERN gpointer value_get_node_image (const GValue* value);
VALA_EXTERN GType node_image_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NodeImage, node_image_unref)
VALA_EXTERN GType draw_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DrawArea, g_object_unref)
VALA_EXTERN ImageEditor* image_editor_new (DrawArea* da);
VALA_EXTERN ImageEditor* image_editor_construct (GType object_type,
                                     DrawArea* da);
VALA_EXTERN gpointer mind_map_ref (gpointer instance);
VALA_EXTERN void mind_map_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_mind_map (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags);
VALA_EXTERN void value_set_mind_map (GValue* value,
                         gpointer v_object);
VALA_EXTERN void value_take_mind_map (GValue* value,
                          gpointer v_object);
VALA_EXTERN gpointer value_get_mind_map (const GValue* value);
VALA_EXTERN GType mind_map_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MindMap, mind_map_unref)
VALA_EXTERN MindMap* draw_area_get_map (DrawArea* self);
VALA_EXTERN ImageManager* mind_map_get_image_manager (MindMap* self);
VALA_EXTERN void image_editor_create_ui (ImageEditor* self,
                             DrawArea* da,
                             ImageManager* im);
VALA_EXTERN void image_editor_edit_image (ImageEditor* self,
                              ImageManager* im,
                              Node* node,
                              gdouble x,
                              gdouble y);
VALA_EXTERN NodeImage* node_get_image (Node* self);
VALA_EXTERN gint node_image_get_id (NodeImage* self);
VALA_EXTERN gpointer style_ref (gpointer instance);
VALA_EXTERN void style_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_style (const gchar* name,
                              const gchar* nick,
                              const gchar* blurb,
                              GType object_type,
                              GParamFlags flags);
VALA_EXTERN void value_set_style (GValue* value,
                      gpointer v_object);
VALA_EXTERN void value_take_style (GValue* value,
                       gpointer v_object);
VALA_EXTERN gpointer value_get_style (const GValue* value);
VALA_EXTERN GType style_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Style, style_unref)
VALA_EXTERN Style* node_get_style (Node* self);
VALA_EXTERN gint* style_get_node_width (Style* self);
VALA_EXTERN NodeImage* node_image_new (ImageManager* im,
                           gint id,
                           gint width);
VALA_EXTERN NodeImage* node_image_construct (GType object_type,
                                 ImageManager* im,
                                 gint id,
                                 gint width);
VALA_EXTERN gboolean node_image_get_valid (NodeImage* self);
VALA_EXTERN gint node_image_get_orig_width (NodeImage* self);
VALA_EXTERN gint node_image_get_crop_x (NodeImage* self);
VALA_EXTERN gint node_image_get_crop_y (NodeImage* self);
VALA_EXTERN gint node_image_get_crop_w (NodeImage* self);
VALA_EXTERN gint node_image_get_crop_h (NodeImage* self);
static void image_editor_set_crop_points (ImageEditor* self);
static gboolean image_editor_initialize (ImageEditor* self,
                                  NodeImage* ni);
static void image_editor_set_cursor_location (ImageEditor* self,
                                       gint x,
                                       gint y);
static void image_editor_set_crop_target (ImageEditor* self,
                                   gdouble x,
                                   gdouble y);
static void image_editor_adjust_crop_points (ImageEditor* self,
                                      gdouble diffx,
                                      gdouble diffy);
VALA_EXTERN GtkDrawingArea* image_editor_create_drawing_area (ImageEditor* self,
                                                  ImageManager* im);
static GtkBox* image_editor_create_status_area (ImageEditor* self);
static GtkBox* image_editor_create_buttons (ImageEditor* self,
                                     DrawArea* da,
                                     ImageManager* im);
static gboolean __lambda105_ (ImageEditor* self,
                       guint keyval,
                       guint keycode,
                       GdkModifierType state);
static void image_editor_action_copy (ImageEditor* self);
static void image_editor_action_paste (ImageEditor* self);
static void image_editor_action_cut (ImageEditor* self);
static void image_editor_action_apply (ImageEditor* self);
static void image_editor_action_cancel (ImageEditor* self);
static void image_editor_action_delete (ImageEditor* self);
static gboolean ___lambda105__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                             guint keyval,
                                                             guint keycode,
                                                             GdkModifierType state,
                                                             gpointer self);
static void __lambda106_ (ImageEditor* self,
                   gdouble x,
                   gdouble y);
static void image_editor_update_ui (ImageEditor* self);
static void ___lambda106__gtk_event_controller_motion_enter (GtkEventControllerMotion* _sender,
                                                      gdouble x,
                                                      gdouble y,
                                                      gpointer self);
static Block23Data* block23_data_ref (Block23Data* _data23_);
static void block23_data_unref (void * _userdata_);
static void __lambda97_ (ImageEditor* self,
                  GtkDrawingArea* d,
                  cairo_t* ctx,
                  gint w,
                  gint h);
static void image_editor_draw_image (ImageEditor* self,
                              cairo_t* ctx);
static void ___lambda97__gtk_drawing_area_draw_func (GtkDrawingArea* drawing_area,
                                              cairo_t* cr,
                                              gint width,
                                              gint height,
                                              gpointer self);
static void __lambda98_ (Block23Data* _data23_,
                  gint n_press,
                  gdouble x,
                  gdouble y);
static void ___lambda98__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                             gint n_press,
                                             gdouble x,
                                             gdouble y,
                                             gpointer self);
static void __lambda99_ (ImageEditor* self,
                  gint n_press,
                  gdouble x,
                  gdouble y);
static void image_editor_set_cursor (ImageEditor* self,
                              const gchar* cursor_name);
static void ___lambda99__gtk_gesture_click_released (GtkGestureClick* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self);
static void __lambda100_ (Block23Data* _data23_,
                   gdouble x,
                   gdouble y);
static void ___lambda100__gtk_event_controller_motion_motion (GtkEventControllerMotion* _sender,
                                                       gdouble x,
                                                       gdouble y,
                                                       gpointer self);
static gboolean __lambda101_ (Block23Data* _data23_,
                       GValue* val,
                       gdouble x,
                       gdouble y);
VALA_EXTERN NodeImage* node_image_new_from_uri (ImageManager* im,
                                    const gchar* uri,
                                    gint width);
VALA_EXTERN NodeImage* node_image_construct_from_uri (GType object_type,
                                          ImageManager* im,
                                          const gchar* uri,
                                          gint width);
static gboolean ___lambda101__gtk_drop_target_drop (GtkDropTarget* _sender,
                                             GValue* value,
                                             gdouble x,
                                             gdouble y,
                                             gpointer self);
static Block24Data* block24_data_ref (Block24Data* _data24_);
static void block24_data_unref (void * _userdata_);
VALA_EXTERN gchar* utils_tooltip_with_accel (const gchar* tooltip,
                                 const gchar* accel);
static void __lambda102_ (Block24Data* _data24_);
VALA_EXTERN void image_manager_choose_image (ImageManager* self,
                                 GtkWindow* parent,
                                 ImageIdFunc func,
                                 gpointer func_target);
VALA_EXTERN GType main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MainWindow, g_object_unref)
VALA_EXTERN MainWindow* draw_area_get_win (DrawArea* self);
static void __lambda103_ (Block24Data* _data24_,
                   gint id);
static void ___lambda103__image_id_func (gint id,
                                  gpointer self);
static void ___lambda102__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void _image_editor_action_cancel_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self);
static void _image_editor_action_apply_gtk_button_clicked (GtkButton* _sender,
                                                    gpointer self);
static void _image_editor_action_copy_gtk_button_clicked (GtkButton* _sender,
                                                   gpointer self);
static void _image_editor_action_cut_gtk_button_clicked (GtkButton* _sender,
                                                  gpointer self);
static void _image_editor_action_paste_gtk_button_clicked (GtkButton* _sender,
                                                    gpointer self);
static void _image_editor_action_delete_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self);
VALA_EXTERN GdkPixbuf* node_image_get_orig_pixbuf (NodeImage* self);
static void image_editor_draw_crop_point (ImageEditor* self,
                                   cairo_t* ctx,
                                   GdkRectangle* crop);
static void image_editor_remove_image (ImageEditor* self,
                                ImageManager* im);
VALA_EXTERN void node_set_image (Node* self,
                     ImageManager* im,
                     NodeImage* ni);
static void image_editor_set_image (ImageEditor* self,
                             ImageManager* im);
VALA_EXTERN void node_image_set_crop_x (NodeImage* self,
                            gint value);
VALA_EXTERN void node_image_set_crop_y (NodeImage* self,
                            gint value);
VALA_EXTERN void node_image_set_crop_w (NodeImage* self,
                            gint value);
VALA_EXTERN void node_image_set_crop_h (NodeImage* self,
                            gint value);
VALA_EXTERN void node_image_set_width (NodeImage* self,
                           gint width);
static gboolean image_editor_image_pasteable (ImageEditor* self);
VALA_EXTERN gboolean minder_clipboard_image_pasteable (void);
VALA_EXTERN gchar* image_manager_get_file (ImageManager* self,
                               gint id);
VALA_EXTERN void minder_clipboard_copy_image (GdkPixbuf* img);
static Block25Data* block25_data_ref (Block25Data* _data25_);
static void block25_data_unref (void * _userdata_);
static void ___lambda104_ (Block25Data* _data25_,
                    GObject* ob,
                    GAsyncResult* res);
VALA_EXTERN GdkPixbuf* utils_texture_to_pixbuf (GdkTexture* texture);
VALA_EXTERN NodeImage* node_image_new_from_pixbuf (ImageManager* im,
                                       GdkPixbuf* buf,
                                       gint width);
VALA_EXTERN NodeImage* node_image_construct_from_pixbuf (GType object_type,
                                             ImageManager* im,
                                             GdkPixbuf* buf,
                                             gint width);
static void ____lambda104__gasync_ready_callback (GObject* source_object,
                                           GAsyncResult* res,
                                           gpointer self);
static void g_cclosure_user_marshal_VOID__NODE_IMAGE (GClosure * closure,
                                               GValue * return_value,
                                               guint n_param_values,
                                               const GValue * param_values,
                                               gpointer invocation_hint,
                                               gpointer marshal_data);
static void image_editor_finalize (ImageEditor * obj);
static GType image_editor_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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
image_editor_get_instance_private (ImageEditor* self)
{
	return G_STRUCT_MEMBER_P (self, ImageEditor_private_offset);
}

static gpointer
_image_manager_ref0 (gpointer self)
{
	return self ? image_manager_ref (self) : NULL;
}

ImageEditor*
image_editor_construct (GType object_type,
                        DrawArea* da)
{
	ImageEditor* self = NULL;
	MindMap* _tmp0_;
	MindMap* _tmp1_;
	ImageManager* _tmp2_;
	ImageManager* _tmp3_;
	ImageManager* _tmp4_;
	GdkRectangle* _tmp5_;
	gchar** _tmp6_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	gchar* _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gchar* _tmp15_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	gchar* _tmp17_;
	gchar** _tmp18_;
	gint _tmp18__length1;
	gchar* _tmp19_;
	gchar** _tmp20_;
	gint _tmp20__length1;
	gchar* _tmp21_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	gchar* _tmp23_;
	gchar** _tmp24_;
	gint _tmp24__length1;
	gchar* _tmp25_;
	gchar** _tmp26_;
	gint _tmp26__length1;
	gchar* _tmp27_;
	MindMap* _tmp28_;
	MindMap* _tmp29_;
	ImageManager* _tmp30_;
	ImageManager* _tmp31_;
	g_return_val_if_fail (da != NULL, NULL);
	self = (ImageEditor*) g_type_create_instance (object_type);
	_tmp0_ = draw_area_get_map (da);
	_tmp1_ = _tmp0_;
	_tmp2_ = mind_map_get_image_manager (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _image_manager_ref0 (_tmp3_);
	_image_manager_unref0 (self->priv->_im);
	self->priv->_im = _tmp4_;
	_tmp5_ = g_new0 (GdkRectangle, 9);
	self->priv->_crop_points = (g_free (self->priv->_crop_points), NULL);
	self->priv->_crop_points = _tmp5_;
	self->priv->_crop_points_length1 = 9;
	self->priv->__crop_points_size_ = self->priv->_crop_points_length1;
	_tmp6_ = g_new0 (gchar*, 8 + 1);
	self->priv->_crop_cursors = (_vala_array_free (self->priv->_crop_cursors, self->priv->_crop_cursors_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_crop_cursors = _tmp6_;
	self->priv->_crop_cursors_length1 = 8;
	self->priv->__crop_cursors_size_ = self->priv->_crop_cursors_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp7_ = FALSE;
			_tmp7_ = TRUE;
			while (TRUE) {
				GdkRectangle* _tmp9_;
				gint _tmp9__length1;
				GdkRectangle* _tmp10_;
				gint _tmp10__length1;
				GdkRectangle _tmp11_ = {0};
				if (!_tmp7_) {
					gint _tmp8_;
					_tmp8_ = i;
					i = _tmp8_ + 1;
				}
				_tmp7_ = FALSE;
				_tmp9_ = self->priv->_crop_points;
				_tmp9__length1 = self->priv->_crop_points_length1;
				if (!(i < _tmp9__length1)) {
					break;
				}
				_tmp10_ = self->priv->_crop_points;
				_tmp10__length1 = self->priv->_crop_points_length1;
				_tmp11_.x = 0;
				_tmp11_.y = 0;
				_tmp11_.width = IMAGE_EDITOR_CROP_WIDTH;
				_tmp11_.height = IMAGE_EDITOR_CROP_WIDTH;
				_tmp10_[i] = _tmp11_;
			}
		}
	}
	self->priv->_scale = 1.0;
	self->priv->_crop_x = 0.0;
	self->priv->_crop_y = 0.0;
	self->priv->_crop_w = 0.0;
	self->priv->_crop_h = 0.0;
	_tmp12_ = self->priv->_crop_cursors;
	_tmp12__length1 = self->priv->_crop_cursors_length1;
	_tmp13_ = g_strdup ("nwse-resize");
	_g_free0 (_tmp12_[0]);
	_tmp12_[0] = _tmp13_;
	_tmp14_ = self->priv->_crop_cursors;
	_tmp14__length1 = self->priv->_crop_cursors_length1;
	_tmp15_ = g_strdup ("ns-resize");
	_g_free0 (_tmp14_[1]);
	_tmp14_[1] = _tmp15_;
	_tmp16_ = self->priv->_crop_cursors;
	_tmp16__length1 = self->priv->_crop_cursors_length1;
	_tmp17_ = g_strdup ("nesw-resize");
	_g_free0 (_tmp16_[2]);
	_tmp16_[2] = _tmp17_;
	_tmp18_ = self->priv->_crop_cursors;
	_tmp18__length1 = self->priv->_crop_cursors_length1;
	_tmp19_ = g_strdup ("ew-resize");
	_g_free0 (_tmp18_[3]);
	_tmp18_[3] = _tmp19_;
	_tmp20_ = self->priv->_crop_cursors;
	_tmp20__length1 = self->priv->_crop_cursors_length1;
	_tmp21_ = g_strdup ("ew-resize");
	_g_free0 (_tmp20_[4]);
	_tmp20_[4] = _tmp21_;
	_tmp22_ = self->priv->_crop_cursors;
	_tmp22__length1 = self->priv->_crop_cursors_length1;
	_tmp23_ = g_strdup ("nesw-resize");
	_g_free0 (_tmp22_[5]);
	_tmp22_[5] = _tmp23_;
	_tmp24_ = self->priv->_crop_cursors;
	_tmp24__length1 = self->priv->_crop_cursors_length1;
	_tmp25_ = g_strdup ("ns-resize");
	_g_free0 (_tmp24_[6]);
	_tmp24_[6] = _tmp25_;
	_tmp26_ = self->priv->_crop_cursors;
	_tmp26__length1 = self->priv->_crop_cursors_length1;
	_tmp27_ = g_strdup ("nwse-resize");
	_g_free0 (_tmp26_[7]);
	_tmp26_[7] = _tmp27_;
	_tmp28_ = draw_area_get_map (da);
	_tmp29_ = _tmp28_;
	_tmp30_ = mind_map_get_image_manager (_tmp29_);
	_tmp31_ = _tmp30_;
	image_editor_create_ui (self, da, _tmp31_);
	return self;
}

ImageEditor*
image_editor_new (DrawArea* da)
{
	return image_editor_construct (TYPE_IMAGE_EDITOR, da);
}

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

void
image_editor_edit_image (ImageEditor* self,
                         ImageManager* im,
                         Node* node,
                         gdouble x,
                         gdouble y)
{
	gint int_x = 0;
	gint int_y = 0;
	GdkRectangle rect = {0};
	GdkRectangle _tmp0_ = {0};
	GtkPopover* _tmp1_;
	GdkRectangle _tmp2_;
	Node* _tmp3_;
	NodeImage* _tmp4_;
	NodeImage* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	Node* _tmp8_;
	Style* _tmp9_;
	Style* _tmp10_;
	gint* _tmp11_;
	gint* _tmp12_;
	NodeImage* _tmp13_;
	NodeImage* _tmp14_;
	gboolean _tmp15_;
	gboolean _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (im != NULL);
	g_return_if_fail (node != NULL);
	int_x = (gint) x;
	int_y = (gint) y;
	_tmp0_.x = int_x;
	_tmp0_.y = int_y;
	_tmp0_.width = 1;
	_tmp0_.height = 1;
	rect = _tmp0_;
	_tmp1_ = self->priv->_popover;
	_tmp2_ = rect;
	g_object_set (_tmp1_, "pointing-to", &_tmp2_, NULL);
	_tmp3_ = _g_object_ref0 (node);
	_g_object_unref0 (self->priv->_node);
	self->priv->_node = _tmp3_;
	_tmp4_ = node_get_image (node);
	_tmp5_ = _tmp4_;
	_tmp6_ = node_image_get_id (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->priv->_node;
	_tmp9_ = node_get_style (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = style_get_node_width (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = node_image_new (im, _tmp7_, *_tmp12_);
	_node_image_unref0 (self->priv->_image);
	self->priv->_image = _tmp13_;
	_tmp14_ = self->priv->_image;
	_tmp15_ = node_image_get_valid (_tmp14_);
	_tmp16_ = _tmp15_;
	if (_tmp16_) {
		NodeImage* _tmp17_;
		gint _tmp18_;
		gint _tmp19_;
		NodeImage* _tmp20_;
		NodeImage* _tmp21_;
		gint _tmp22_;
		gint _tmp23_;
		NodeImage* _tmp24_;
		NodeImage* _tmp25_;
		gint _tmp26_;
		gint _tmp27_;
		NodeImage* _tmp28_;
		NodeImage* _tmp29_;
		gint _tmp30_;
		gint _tmp31_;
		NodeImage* _tmp32_;
		NodeImage* _tmp33_;
		gint _tmp34_;
		gint _tmp35_;
		GdkRectangle* _tmp36_;
		gint _tmp36__length1;
		NodeImage* _tmp37_;
		gint _tmp38_;
		gint _tmp39_;
		GdkRectangle* _tmp40_;
		gint _tmp40__length1;
		NodeImage* _tmp41_;
		gint _tmp42_;
		gint _tmp43_;
		GtkDrawingArea* _tmp44_;
		GtkPopover* _tmp45_;
		_tmp17_ = self->priv->_image;
		_tmp18_ = node_image_get_orig_width (_tmp17_);
		_tmp19_ = _tmp18_;
		self->priv->_scale = ((gdouble) IMAGE_EDITOR_EDIT_WIDTH) / _tmp19_;
		_tmp20_ = node_get_image (node);
		_tmp21_ = _tmp20_;
		_tmp22_ = node_image_get_crop_x (_tmp21_);
		_tmp23_ = _tmp22_;
		self->priv->_crop_x = (gdouble) _tmp23_;
		_tmp24_ = node_get_image (node);
		_tmp25_ = _tmp24_;
		_tmp26_ = node_image_get_crop_y (_tmp25_);
		_tmp27_ = _tmp26_;
		self->priv->_crop_y = (gdouble) _tmp27_;
		_tmp28_ = node_get_image (node);
		_tmp29_ = _tmp28_;
		_tmp30_ = node_image_get_crop_w (_tmp29_);
		_tmp31_ = _tmp30_;
		self->priv->_crop_w = (gdouble) _tmp31_;
		_tmp32_ = node_get_image (node);
		_tmp33_ = _tmp32_;
		_tmp34_ = node_image_get_crop_h (_tmp33_);
		_tmp35_ = _tmp34_;
		self->priv->_crop_h = (gdouble) _tmp35_;
		_tmp36_ = self->priv->_crop_points;
		_tmp36__length1 = self->priv->_crop_points_length1;
		_tmp37_ = self->priv->_image;
		_tmp38_ = node_image_get_crop_w (_tmp37_);
		_tmp39_ = _tmp38_;
		_tmp36_[8].width = _tmp39_;
		_tmp40_ = self->priv->_crop_points;
		_tmp40__length1 = self->priv->_crop_points_length1;
		_tmp41_ = self->priv->_image;
		_tmp42_ = node_image_get_crop_h (_tmp41_);
		_tmp43_ = _tmp42_;
		_tmp40_[8].height = _tmp43_;
		image_editor_set_crop_points (self);
		_tmp44_ = self->priv->_da;
		gtk_widget_queue_draw ((GtkWidget*) _tmp44_);
		_tmp45_ = self->priv->_popover;
		gtk_popover_popup (_tmp45_);
	}
}

static gpointer
_node_image_ref0 (gpointer self)
{
	return self ? node_image_ref (self) : NULL;
}

static gboolean
image_editor_initialize (ImageEditor* self,
                         NodeImage* ni)
{
	NodeImage* _tmp0_;
	NodeImage* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	NodeImage* _tmp28_;
	gboolean _tmp29_;
	gboolean _tmp30_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (ni != NULL, FALSE);
	_tmp0_ = _node_image_ref0 (ni);
	_node_image_unref0 (self->priv->_image);
	self->priv->_image = _tmp0_;
	_tmp1_ = self->priv->_image;
	_tmp2_ = node_image_get_valid (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		NodeImage* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		NodeImage* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		NodeImage* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		NodeImage* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		NodeImage* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		GdkRectangle* _tmp19_;
		gint _tmp19__length1;
		NodeImage* _tmp20_;
		gint _tmp21_;
		gint _tmp22_;
		GdkRectangle* _tmp23_;
		gint _tmp23__length1;
		NodeImage* _tmp24_;
		gint _tmp25_;
		gint _tmp26_;
		GtkDrawingArea* _tmp27_;
		_tmp4_ = self->priv->_image;
		_tmp5_ = node_image_get_orig_width (_tmp4_);
		_tmp6_ = _tmp5_;
		self->priv->_scale = ((gdouble) IMAGE_EDITOR_EDIT_WIDTH) / _tmp6_;
		_tmp7_ = self->priv->_image;
		_tmp8_ = node_image_get_crop_x (_tmp7_);
		_tmp9_ = _tmp8_;
		self->priv->_crop_x = (gdouble) _tmp9_;
		_tmp10_ = self->priv->_image;
		_tmp11_ = node_image_get_crop_y (_tmp10_);
		_tmp12_ = _tmp11_;
		self->priv->_crop_y = (gdouble) _tmp12_;
		_tmp13_ = self->priv->_image;
		_tmp14_ = node_image_get_crop_w (_tmp13_);
		_tmp15_ = _tmp14_;
		self->priv->_crop_w = (gdouble) _tmp15_;
		_tmp16_ = self->priv->_image;
		_tmp17_ = node_image_get_crop_h (_tmp16_);
		_tmp18_ = _tmp17_;
		self->priv->_crop_h = (gdouble) _tmp18_;
		_tmp19_ = self->priv->_crop_points;
		_tmp19__length1 = self->priv->_crop_points_length1;
		_tmp20_ = self->priv->_image;
		_tmp21_ = node_image_get_crop_w (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp19_[8].width = _tmp22_;
		_tmp23_ = self->priv->_crop_points;
		_tmp23__length1 = self->priv->_crop_points_length1;
		_tmp24_ = self->priv->_image;
		_tmp25_ = node_image_get_crop_h (_tmp24_);
		_tmp26_ = _tmp25_;
		_tmp23_[8].height = _tmp26_;
		image_editor_set_crop_points (self);
		image_editor_set_cursor_location (self, 0, 0);
		_tmp27_ = self->priv->_da;
		gtk_widget_queue_draw ((GtkWidget*) _tmp27_);
	}
	_tmp28_ = self->priv->_image;
	_tmp29_ = node_image_get_valid (_tmp28_);
	_tmp30_ = _tmp29_;
	result = _tmp30_;
	return result;
}

static void
image_editor_set_crop_points (ImageEditor* self)
{
	gdouble crop_width = 0.0;
	gint x0 = 0;
	gint x1 = 0;
	gint x2 = 0;
	gint y0 = 0;
	gint y1 = 0;
	gint y2 = 0;
	GdkRectangle* _tmp0_;
	gint _tmp0__length1;
	GdkRectangle* _tmp1_;
	gint _tmp1__length1;
	GdkRectangle* _tmp2_;
	gint _tmp2__length1;
	GdkRectangle* _tmp3_;
	gint _tmp3__length1;
	GdkRectangle* _tmp4_;
	gint _tmp4__length1;
	GdkRectangle* _tmp5_;
	gint _tmp5__length1;
	GdkRectangle* _tmp6_;
	gint _tmp6__length1;
	GdkRectangle* _tmp7_;
	gint _tmp7__length1;
	GdkRectangle* _tmp8_;
	gint _tmp8__length1;
	GdkRectangle* _tmp9_;
	gint _tmp9__length1;
	GdkRectangle* _tmp10_;
	gint _tmp10__length1;
	GdkRectangle* _tmp11_;
	gint _tmp11__length1;
	GdkRectangle* _tmp12_;
	gint _tmp12__length1;
	GdkRectangle* _tmp13_;
	gint _tmp13__length1;
	GdkRectangle* _tmp14_;
	gint _tmp14__length1;
	GdkRectangle* _tmp15_;
	gint _tmp15__length1;
	GdkRectangle* _tmp20_;
	gint _tmp20__length1;
	GdkRectangle* _tmp21_;
	gint _tmp21__length1;
	GdkRectangle* _tmp22_;
	gint _tmp22__length1;
	GdkRectangle* _tmp23_;
	gint _tmp23__length1;
	GtkLabel* _tmp24_;
	GdkRectangle* _tmp25_;
	gint _tmp25__length1;
	GdkRectangle _tmp26_;
	GdkRectangle* _tmp27_;
	gint _tmp27__length1;
	GdkRectangle _tmp28_;
	GdkRectangle* _tmp29_;
	gint _tmp29__length1;
	GdkRectangle _tmp30_;
	GdkRectangle* _tmp31_;
	gint _tmp31__length1;
	GdkRectangle _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	g_return_if_fail (self != NULL);
	crop_width = IMAGE_EDITOR_CROP_WIDTH / self->priv->_scale;
	x0 = (gint) self->priv->_crop_x;
	x1 = (gint) ((self->priv->_crop_x + (self->priv->_crop_w / 2)) - (crop_width / 2));
	x2 = (gint) ((self->priv->_crop_x + self->priv->_crop_w) - crop_width);
	y0 = (gint) self->priv->_crop_y;
	y1 = (gint) ((self->priv->_crop_y + (self->priv->_crop_h / 2)) - (crop_width / 2));
	y2 = (gint) ((self->priv->_crop_y + self->priv->_crop_h) - crop_width);
	_tmp0_ = self->priv->_crop_points;
	_tmp0__length1 = self->priv->_crop_points_length1;
	_tmp0_[0].x = x0;
	_tmp1_ = self->priv->_crop_points;
	_tmp1__length1 = self->priv->_crop_points_length1;
	_tmp1_[0].y = y0;
	_tmp2_ = self->priv->_crop_points;
	_tmp2__length1 = self->priv->_crop_points_length1;
	_tmp2_[1].x = x1;
	_tmp3_ = self->priv->_crop_points;
	_tmp3__length1 = self->priv->_crop_points_length1;
	_tmp3_[1].y = y0;
	_tmp4_ = self->priv->_crop_points;
	_tmp4__length1 = self->priv->_crop_points_length1;
	_tmp4_[2].x = x2;
	_tmp5_ = self->priv->_crop_points;
	_tmp5__length1 = self->priv->_crop_points_length1;
	_tmp5_[2].y = y0;
	_tmp6_ = self->priv->_crop_points;
	_tmp6__length1 = self->priv->_crop_points_length1;
	_tmp6_[3].x = x0;
	_tmp7_ = self->priv->_crop_points;
	_tmp7__length1 = self->priv->_crop_points_length1;
	_tmp7_[3].y = y1;
	_tmp8_ = self->priv->_crop_points;
	_tmp8__length1 = self->priv->_crop_points_length1;
	_tmp8_[4].x = x2;
	_tmp9_ = self->priv->_crop_points;
	_tmp9__length1 = self->priv->_crop_points_length1;
	_tmp9_[4].y = y1;
	_tmp10_ = self->priv->_crop_points;
	_tmp10__length1 = self->priv->_crop_points_length1;
	_tmp10_[5].x = x0;
	_tmp11_ = self->priv->_crop_points;
	_tmp11__length1 = self->priv->_crop_points_length1;
	_tmp11_[5].y = y2;
	_tmp12_ = self->priv->_crop_points;
	_tmp12__length1 = self->priv->_crop_points_length1;
	_tmp12_[6].x = x1;
	_tmp13_ = self->priv->_crop_points;
	_tmp13__length1 = self->priv->_crop_points_length1;
	_tmp13_[6].y = y2;
	_tmp14_ = self->priv->_crop_points;
	_tmp14__length1 = self->priv->_crop_points_length1;
	_tmp14_[7].x = x2;
	_tmp15_ = self->priv->_crop_points;
	_tmp15__length1 = self->priv->_crop_points_length1;
	_tmp15_[7].y = y2;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp16_ = FALSE;
			_tmp16_ = TRUE;
			while (TRUE) {
				GdkRectangle* _tmp18_;
				gint _tmp18__length1;
				GdkRectangle* _tmp19_;
				gint _tmp19__length1;
				if (!_tmp16_) {
					gint _tmp17_;
					_tmp17_ = i;
					i = _tmp17_ + 1;
				}
				_tmp16_ = FALSE;
				if (!(i < 8)) {
					break;
				}
				_tmp18_ = self->priv->_crop_points;
				_tmp18__length1 = self->priv->_crop_points_length1;
				_tmp18_[i].width = (gint) crop_width;
				_tmp19_ = self->priv->_crop_points;
				_tmp19__length1 = self->priv->_crop_points_length1;
				_tmp19_[i].height = (gint) crop_width;
			}
		}
	}
	_tmp20_ = self->priv->_crop_points;
	_tmp20__length1 = self->priv->_crop_points_length1;
	_tmp20_[8].x = x0;
	_tmp21_ = self->priv->_crop_points;
	_tmp21__length1 = self->priv->_crop_points_length1;
	_tmp21_[8].y = y0;
	_tmp22_ = self->priv->_crop_points;
	_tmp22__length1 = self->priv->_crop_points_length1;
	_tmp22_[8].width = (gint) self->priv->_crop_w;
	_tmp23_ = self->priv->_crop_points;
	_tmp23__length1 = self->priv->_crop_points_length1;
	_tmp23_[8].height = (gint) self->priv->_crop_h;
	_tmp24_ = self->priv->_status_crop;
	_tmp25_ = self->priv->_crop_points;
	_tmp25__length1 = self->priv->_crop_points_length1;
	_tmp26_ = _tmp25_[8];
	_tmp27_ = self->priv->_crop_points;
	_tmp27__length1 = self->priv->_crop_points_length1;
	_tmp28_ = _tmp27_[8];
	_tmp29_ = self->priv->_crop_points;
	_tmp29__length1 = self->priv->_crop_points_length1;
	_tmp30_ = _tmp29_[8];
	_tmp31_ = self->priv->_crop_points;
	_tmp31__length1 = self->priv->_crop_points_length1;
	_tmp32_ = _tmp31_[8];
	_tmp33_ = g_strdup_printf (_ ("Crop Area: %d,%d %3dx%3d"), _tmp26_.x, _tmp28_.y, _tmp30_.width, _tmp32_.height);
	_tmp34_ = _tmp33_;
	gtk_label_set_label (_tmp24_, _tmp34_);
	_g_free0 (_tmp34_);
}

static void
image_editor_set_crop_target (ImageEditor* self,
                              gdouble x,
                              gdouble y)
{
	gint int_x = 0;
	gint int_y = 0;
	GdkRectangle cursor = {0};
	GdkRectangle _tmp0_ = {0};
	GdkRectangle tmp = {0};
	gint i = 0;
	GdkRectangle* _tmp1_;
	gint _tmp1__length1;
	g_return_if_fail (self != NULL);
	int_x = (gint) x;
	int_y = (gint) y;
	_tmp0_.x = int_x;
	_tmp0_.y = int_y;
	_tmp0_.width = 1;
	_tmp0_.height = 1;
	cursor = _tmp0_;
	i = 0;
	_tmp1_ = self->priv->_crop_points;
	_tmp1__length1 = self->priv->_crop_points_length1;
	{
		GdkRectangle* crop_point_collection = NULL;
		gint crop_point_collection_length1 = 0;
		gint _crop_point_collection_size_ = 0;
		gint crop_point_it = 0;
		crop_point_collection = _tmp1_;
		crop_point_collection_length1 = _tmp1__length1;
		for (crop_point_it = 0; crop_point_it < crop_point_collection_length1; crop_point_it = crop_point_it + 1) {
			GdkRectangle crop_point = {0};
			crop_point = crop_point_collection[crop_point_it];
			{
				GdkRectangle _tmp2_;
				GdkRectangle _tmp3_ = {0};
				gboolean _tmp4_;
				gint _tmp5_;
				_tmp2_ = cursor;
				_tmp4_ = gdk_rectangle_intersect (&crop_point, &_tmp2_, &_tmp3_);
				tmp = _tmp3_;
				if (_tmp4_) {
					self->priv->_crop_target = i;
					return;
				}
				_tmp5_ = i;
				i = _tmp5_ + 1;
			}
		}
	}
	self->priv->_crop_target = -1;
}

static void
image_editor_adjust_crop_points (ImageEditor* self,
                                 gdouble diffx,
                                 gdouble diffy)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_crop_target != -1) {
		gdouble x = 0.0;
		gdouble y = 0.0;
		gdouble w = 0.0;
		gdouble h = 0.0;
		gboolean _tmp0_ = FALSE;
		gboolean _tmp1_ = FALSE;
		gboolean _tmp5_ = FALSE;
		gboolean _tmp6_ = FALSE;
		x = self->priv->_crop_x;
		y = self->priv->_crop_y;
		w = self->priv->_crop_w;
		h = self->priv->_crop_h;
		switch (self->priv->_crop_target) {
			case 0:
			{
				x += diffx;
				y += diffy;
				w -= diffx;
				h -= diffy;
				break;
			}
			case 1:
			{
				y += diffy;
				h -= diffy;
				break;
			}
			case 2:
			{
				y += diffy;
				w += diffx;
				h -= diffy;
				break;
			}
			case 3:
			{
				x += diffx;
				w -= diffx;
				break;
			}
			case 4:
			{
				w += diffx;
				break;
			}
			case 5:
			{
				x += diffx;
				w -= diffx;
				h += diffy;
				break;
			}
			case 6:
			{
				h += diffy;
				break;
			}
			case 7:
			{
				w += diffx;
				h += diffy;
				break;
			}
			case 8:
			{
				x += diffx;
				y += diffy;
				break;
			}
			default:
			break;
		}
		if (x >= ((gdouble) 0)) {
			GtkDrawingArea* _tmp2_;
			gint _tmp3_;
			gint _tmp4_;
			_tmp2_ = self->priv->_da;
			g_object_get ((GtkWidget*) _tmp2_, "width-request", &_tmp3_, NULL);
			_tmp4_ = _tmp3_;
			_tmp1_ = (x + w) <= ((gdouble) _tmp4_);
		} else {
			_tmp1_ = FALSE;
		}
		if (_tmp1_) {
			_tmp0_ = w >= IMAGE_EDITOR_MIN_WIDTH;
		} else {
			_tmp0_ = FALSE;
		}
		if (_tmp0_) {
			self->priv->_crop_x = x;
			self->priv->_crop_w = w;
		}
		if (y >= ((gdouble) 0)) {
			GtkDrawingArea* _tmp7_;
			gint _tmp8_;
			gint _tmp9_;
			_tmp7_ = self->priv->_da;
			g_object_get ((GtkWidget*) _tmp7_, "height-request", &_tmp8_, NULL);
			_tmp9_ = _tmp8_;
			_tmp6_ = (y + h) <= ((gdouble) _tmp9_);
		} else {
			_tmp6_ = FALSE;
		}
		if (_tmp6_) {
			_tmp5_ = h >= IMAGE_EDITOR_MIN_WIDTH;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			self->priv->_crop_y = y;
			self->priv->_crop_h = h;
		}
		image_editor_set_crop_points (self);
	}
}

static gboolean
__lambda105_ (ImageEditor* self,
              guint keyval,
              guint keycode,
              GdkModifierType state)
{
	gboolean control = FALSE;
	gboolean result;
	control = (gboolean) (state & GDK_CONTROL_MASK);
	if (control) {
		switch (keyval) {
			case 99:
			{
				image_editor_action_copy (self);
				break;
			}
			case 118:
			{
				image_editor_action_paste (self);
				break;
			}
			case 120:
			{
				image_editor_action_cut (self);
				break;
			}
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else {
		switch (keyval) {
			case 65293:
			{
				image_editor_action_apply (self);
				break;
			}
			case 65307:
			{
				image_editor_action_cancel (self);
				break;
			}
			case 65535:
			{
				image_editor_action_delete (self);
				break;
			}
			default:
			{
				result = FALSE;
				return result;
			}
		}
	}
	result = TRUE;
	return result;
}

static gboolean
___lambda105__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                    guint keyval,
                                                    guint keycode,
                                                    GdkModifierType state,
                                                    gpointer self)
{
	gboolean result;
	result = __lambda105_ ((ImageEditor*) self, keyval, keycode, state);
	return result;
}

static void
__lambda106_ (ImageEditor* self,
              gdouble x,
              gdouble y)
{
	image_editor_update_ui (self);
}

static void
___lambda106__gtk_event_controller_motion_enter (GtkEventControllerMotion* _sender,
                                                 gdouble x,
                                                 gdouble y,
                                                 gpointer self)
{
	__lambda106_ ((ImageEditor*) self, x, y);
}

void
image_editor_create_ui (ImageEditor* self,
                        DrawArea* da,
                        ImageManager* im)
{
	GtkDrawingArea* _tmp0_;
	GtkBox* status = NULL;
	GtkBox* _tmp1_;
	GtkBox* buttons = NULL;
	GtkBox* _tmp2_;
	GtkBox* box = NULL;
	GtkBox* _tmp3_ = NULL;
	GtkDrawingArea* _tmp4_;
	GtkWidget* _tmp5_;
	GtkPopover* _tmp6_ = NULL;
	GtkPopover* _tmp7_;
	GtkEventControllerKey* key = NULL;
	GtkEventControllerKey* _tmp8_;
	GtkEventController* _tmp9_;
	GtkEventControllerMotion* motion = NULL;
	GtkEventControllerMotion* _tmp10_;
	GtkEventController* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (da != NULL);
	g_return_if_fail (im != NULL);
	_tmp0_ = image_editor_create_drawing_area (self, im);
	_g_object_unref0 (self->priv->_da);
	self->priv->_da = _tmp0_;
	_tmp1_ = image_editor_create_status_area (self);
	status = _tmp1_;
	_tmp2_ = image_editor_create_buttons (self, da, im);
	buttons = _tmp2_;
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp3_, 5);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp3_, 5);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp3_, 5);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp3_, 5);
	g_object_ref_sink (_tmp3_);
	box = _tmp3_;
	_tmp4_ = self->priv->_da;
	gtk_box_append (box, (GtkWidget*) _tmp4_);
	gtk_box_append (box, (GtkWidget*) status);
	gtk_box_append (box, (GtkWidget*) buttons);
	_tmp5_ = _g_object_ref0 ((GtkWidget*) box);
	_tmp6_ = (GtkPopover*) gtk_popover_new ();
	gtk_popover_set_child (_tmp6_, _tmp5_);
	_g_object_unref0 (_tmp5_);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->priv->_popover);
	self->priv->_popover = _tmp6_;
	_tmp7_ = self->priv->_popover;
	gtk_widget_set_parent ((GtkWidget*) _tmp7_, (GtkWidget*) da);
	_tmp8_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	key = _tmp8_;
	_tmp9_ = _g_object_ref0 ((GtkEventController*) key);
	gtk_widget_add_controller ((GtkWidget*) box, _tmp9_);
	g_signal_connect (key, "key-pressed", (GCallback) ___lambda105__gtk_event_controller_key_key_pressed, self);
	_tmp10_ = (GtkEventControllerMotion*) gtk_event_controller_motion_new ();
	motion = _tmp10_;
	_tmp11_ = _g_object_ref0 ((GtkEventController*) motion);
	gtk_widget_add_controller ((GtkWidget*) box, _tmp11_);
	g_signal_connect (motion, "enter", (GCallback) ___lambda106__gtk_event_controller_motion_enter, self);
	image_editor_update_ui (self);
	_g_object_unref0 (motion);
	_g_object_unref0 (key);
	_g_object_unref0 (box);
	_g_object_unref0 (buttons);
	_g_object_unref0 (status);
}

static Block23Data*
block23_data_ref (Block23Data* _data23_)
{
	g_atomic_int_inc (&_data23_->_ref_count_);
	return _data23_;
}

static void
block23_data_unref (void * _userdata_)
{
	Block23Data* _data23_;
	_data23_ = (Block23Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data23_->_ref_count_)) {
		ImageEditor* self;
		self = _data23_->self;
		_g_object_unref0 (_data23_->da);
		_image_manager_unref0 (_data23_->im);
		_image_editor_unref0 (self);
		g_slice_free (Block23Data, _data23_);
	}
}

static void
__lambda97_ (ImageEditor* self,
             GtkDrawingArea* d,
             cairo_t* ctx,
             gint w,
             gint h)
{
	g_return_if_fail (d != NULL);
	g_return_if_fail (ctx != NULL);
	image_editor_draw_image (self, ctx);
}

static void
___lambda97__gtk_drawing_area_draw_func (GtkDrawingArea* drawing_area,
                                         cairo_t* cr,
                                         gint width,
                                         gint height,
                                         gpointer self)
{
	__lambda97_ ((ImageEditor*) self, drawing_area, cr, width, height);
}

static void
__lambda98_ (Block23Data* _data23_,
             gint n_press,
             gdouble x,
             gdouble y)
{
	ImageEditor* self;
	gdouble scaled_x = 0.0;
	gdouble scaled_y = 0.0;
	self = _data23_->self;
	scaled_x = x / self->priv->_scale;
	scaled_y = y / self->priv->_scale;
	image_editor_set_crop_target (self, scaled_x, scaled_y);
	if (self->priv->_crop_target == 8) {
		GdkCursor* _tmp0_;
		GdkCursor* _tmp1_;
		_tmp0_ = gdk_cursor_new_from_name ("grabbing", NULL);
		_tmp1_ = _tmp0_;
		gtk_widget_set_cursor ((GtkWidget*) _data23_->da, _tmp1_);
		_g_object_unref0 (_tmp1_);
	}
	self->priv->_press_x = scaled_x;
	self->priv->_press_y = scaled_y;
}

static void
___lambda98__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                        gint n_press,
                                        gdouble x,
                                        gdouble y,
                                        gpointer self)
{
	__lambda98_ (self, n_press, x, y);
}

static void
__lambda99_ (ImageEditor* self,
             gint n_press,
             gdouble x,
             gdouble y)
{
	self->priv->_crop_target = -1;
	image_editor_set_cursor (self, NULL);
}

static void
___lambda99__gtk_gesture_click_released (GtkGestureClick* _sender,
                                         gint n_press,
                                         gdouble x,
                                         gdouble y,
                                         gpointer self)
{
	__lambda99_ ((ImageEditor*) self, n_press, x, y);
}

static void
__lambda100_ (Block23Data* _data23_,
              gdouble x,
              gdouble y)
{
	ImageEditor* self;
	gdouble scaled_x = 0.0;
	gdouble scaled_y = 0.0;
	self = _data23_->self;
	scaled_x = x / self->priv->_scale;
	scaled_y = y / self->priv->_scale;
	if (self->priv->_crop_target == -1) {
		gboolean _tmp0_ = FALSE;
		image_editor_set_crop_target (self, scaled_x, scaled_y);
		if (self->priv->_crop_target >= 0) {
			_tmp0_ = self->priv->_crop_target < 8;
		} else {
			_tmp0_ = FALSE;
		}
		if (_tmp0_) {
			gchar** _tmp1_;
			gint _tmp1__length1;
			const gchar* _tmp2_;
			_tmp1_ = self->priv->_crop_cursors;
			_tmp1__length1 = self->priv->_crop_cursors_length1;
			_tmp2_ = _tmp1_[self->priv->_crop_target];
			image_editor_set_cursor (self, _tmp2_);
		} else {
			image_editor_set_cursor (self, NULL);
		}
		self->priv->_crop_target = -1;
	} else {
		image_editor_adjust_crop_points (self, scaled_x - self->priv->_press_x, scaled_y - self->priv->_press_y);
		gtk_widget_queue_draw ((GtkWidget*) _data23_->da);
	}
	image_editor_set_cursor_location (self, (gint) scaled_x, (gint) scaled_y);
}

static void
___lambda100__gtk_event_controller_motion_motion (GtkEventControllerMotion* _sender,
                                                  gdouble x,
                                                  gdouble y,
                                                  gpointer self)
{
	__lambda100_ (self, x, y);
}

static gboolean
__lambda101_ (Block23Data* _data23_,
              GValue* val,
              gdouble x,
              gdouble y)
{
	ImageEditor* self;
	GFile* file = NULL;
	GValue _tmp0_;
	GFile* _tmp1_;
	NodeImage* ni = NULL;
	GFile* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	Node* _tmp5_;
	Style* _tmp6_;
	Style* _tmp7_;
	gint* _tmp8_;
	gint* _tmp9_;
	NodeImage* _tmp10_;
	NodeImage* _tmp11_;
	gboolean _tmp12_ = FALSE;
	NodeImage* _tmp13_;
	gboolean result;
	self = _data23_->self;
	g_return_val_if_fail (val != NULL, FALSE);
	_tmp0_ = *val;
	_tmp1_ = _g_object_ref0 (g_value_get_object (&_tmp0_));
	file = _tmp1_;
	_tmp2_ = file;
	_tmp3_ = g_file_get_uri (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->_node;
	_tmp6_ = node_get_style (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = style_get_node_width (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = node_image_new_from_uri (_data23_->im, _tmp4_, *_tmp9_);
	_tmp11_ = _tmp10_;
	_g_free0 (_tmp4_);
	ni = _tmp11_;
	_tmp13_ = ni;
	if (_tmp13_ != NULL) {
		NodeImage* _tmp14_;
		_tmp14_ = ni;
		_tmp12_ = image_editor_initialize (self, _tmp14_);
	} else {
		_tmp12_ = FALSE;
	}
	result = _tmp12_;
	_node_image_unref0 (ni);
	_g_object_unref0 (file);
	return result;
}

static gboolean
___lambda101__gtk_drop_target_drop (GtkDropTarget* _sender,
                                    GValue* value,
                                    gdouble x,
                                    gdouble y,
                                    gpointer self)
{
	gboolean result;
	result = __lambda101_ (self, value, x, y);
	return result;
}

GtkDrawingArea*
image_editor_create_drawing_area (ImageEditor* self,
                                  ImageManager* im)
{
	Block23Data* _data23_;
	ImageManager* _tmp0_;
	GtkDrawingArea* _tmp1_ = NULL;
	GtkGestureClick* click = NULL;
	GtkGestureClick* _tmp2_;
	GtkEventController* _tmp3_;
	GtkEventControllerMotion* motion = NULL;
	GtkEventControllerMotion* _tmp4_;
	GtkEventController* _tmp5_;
	GtkDropTarget* drop = NULL;
	GtkDropTarget* _tmp6_;
	GtkEventController* _tmp7_;
	GtkDrawingArea* _tmp8_;
	GtkDrawingArea* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (im != NULL, NULL);
	_data23_ = g_slice_new0 (Block23Data);
	_data23_->_ref_count_ = 1;
	_data23_->self = image_editor_ref (self);
	_tmp0_ = _image_manager_ref0 (im);
	_image_manager_unref0 (_data23_->im);
	_data23_->im = _tmp0_;
	_tmp1_ = (GtkDrawingArea*) gtk_drawing_area_new ();
	g_object_set ((GtkWidget*) _tmp1_, "width-request", IMAGE_EDITOR_EDIT_WIDTH, NULL);
	g_object_set ((GtkWidget*) _tmp1_, "height-request", IMAGE_EDITOR_EDIT_HEIGHT, NULL);
	g_object_ref_sink (_tmp1_);
	_data23_->da = _tmp1_;
	gtk_drawing_area_set_draw_func (_data23_->da, ___lambda97__gtk_drawing_area_draw_func, image_editor_ref (self), image_editor_unref);
	gtk_widget_add_css_class ((GtkWidget*) _data23_->da, "canvas");
	_tmp2_ = (GtkGestureClick*) gtk_gesture_click_new ();
	click = _tmp2_;
	_tmp3_ = _g_object_ref0 ((GtkEventController*) click);
	gtk_widget_add_controller ((GtkWidget*) _data23_->da, _tmp3_);
	g_signal_connect_data (click, "pressed", (GCallback) ___lambda98__gtk_gesture_click_pressed, block23_data_ref (_data23_), (GClosureNotify) block23_data_unref, 0);
	g_signal_connect (click, "released", (GCallback) ___lambda99__gtk_gesture_click_released, self);
	_tmp4_ = (GtkEventControllerMotion*) gtk_event_controller_motion_new ();
	motion = _tmp4_;
	_tmp5_ = _g_object_ref0 ((GtkEventController*) motion);
	gtk_widget_add_controller ((GtkWidget*) _data23_->da, _tmp5_);
	g_signal_connect_data (motion, "motion", (GCallback) ___lambda100__gtk_event_controller_motion_motion, block23_data_ref (_data23_), (GClosureNotify) block23_data_unref, 0);
	_tmp6_ = gtk_drop_target_new (g_file_get_type (), GDK_ACTION_COPY);
	drop = _tmp6_;
	_tmp7_ = _g_object_ref0 ((GtkEventController*) drop);
	gtk_widget_add_controller ((GtkWidget*) _data23_->da, _tmp7_);
	g_signal_connect_data (drop, "drop", (GCallback) ___lambda101__gtk_drop_target_drop, block23_data_ref (_data23_), (GClosureNotify) block23_data_unref, 0);
	_tmp8_ = _g_object_ref0 (_data23_->da);
	result = _tmp8_;
	_g_object_unref0 (drop);
	_g_object_unref0 (motion);
	_g_object_unref0 (click);
	block23_data_unref (_data23_);
	_data23_ = NULL;
	return result;
}

static GtkBox*
image_editor_create_status_area (ImageEditor* self)
{
	GtkBox* box = NULL;
	GtkBox* _tmp0_ = NULL;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkBox* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
	gtk_box_set_homogeneous (_tmp0_, TRUE);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->_status_cursor);
	self->priv->_status_cursor = _tmp1_;
	_tmp2_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->_status_crop);
	self->priv->_status_crop = _tmp2_;
	_tmp3_ = self->priv->_status_cursor;
	gtk_box_append (box, (GtkWidget*) _tmp3_);
	_tmp4_ = self->priv->_status_crop;
	gtk_box_append (box, (GtkWidget*) _tmp4_);
	result = box;
	return result;
}

static void
image_editor_set_cursor_location (ImageEditor* self,
                                  gint x,
                                  gint y)
{
	GtkLabel* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_status_cursor;
	_tmp1_ = g_strdup_printf (_ ("Cursor: %3d,%3d"), x, y);
	_tmp2_ = _tmp1_;
	gtk_label_set_label (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
}

static Block24Data*
block24_data_ref (Block24Data* _data24_)
{
	g_atomic_int_inc (&_data24_->_ref_count_);
	return _data24_;
}

static void
block24_data_unref (void * _userdata_)
{
	Block24Data* _data24_;
	_data24_ = (Block24Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data24_->_ref_count_)) {
		ImageEditor* self;
		self = _data24_->self;
		_g_object_unref0 (_data24_->da);
		_image_manager_unref0 (_data24_->im);
		_image_editor_unref0 (self);
		g_slice_free (Block24Data, _data24_);
	}
}

static void
__lambda103_ (Block24Data* _data24_,
              gint id)
{
	ImageEditor* self;
	NodeImage* ni = NULL;
	Node* _tmp0_;
	Style* _tmp1_;
	Style* _tmp2_;
	gint* _tmp3_;
	gint* _tmp4_;
	NodeImage* _tmp5_;
	NodeImage* _tmp6_;
	self = _data24_->self;
	_tmp0_ = self->priv->_node;
	_tmp1_ = node_get_style (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = style_get_node_width (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = node_image_new (_data24_->im, id, *_tmp4_);
	ni = _tmp5_;
	_tmp6_ = ni;
	if (_tmp6_ != NULL) {
		NodeImage* _tmp7_;
		_tmp7_ = ni;
		image_editor_initialize (self, _tmp7_);
	}
	_node_image_unref0 (ni);
}

static void
___lambda103__image_id_func (gint id,
                             gpointer self)
{
	__lambda103_ (self, id);
}

static void
__lambda102_ (Block24Data* _data24_)
{
	ImageEditor* self;
	MainWindow* _tmp0_;
	MainWindow* _tmp1_;
	self = _data24_->self;
	_tmp0_ = draw_area_get_win (_data24_->da);
	_tmp1_ = _tmp0_;
	image_manager_choose_image (_data24_->im, (GtkWindow*) _tmp1_, ___lambda103__image_id_func, _data24_);
}

static void
___lambda102__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda102_ (self);
}

static void
_image_editor_action_cancel_gtk_button_clicked (GtkButton* _sender,
                                                gpointer self)
{
	image_editor_action_cancel ((ImageEditor*) self);
}

static void
_image_editor_action_apply_gtk_button_clicked (GtkButton* _sender,
                                               gpointer self)
{
	image_editor_action_apply ((ImageEditor*) self);
}

static void
_image_editor_action_copy_gtk_button_clicked (GtkButton* _sender,
                                              gpointer self)
{
	image_editor_action_copy ((ImageEditor*) self);
}

static void
_image_editor_action_cut_gtk_button_clicked (GtkButton* _sender,
                                             gpointer self)
{
	image_editor_action_cut ((ImageEditor*) self);
}

static void
_image_editor_action_paste_gtk_button_clicked (GtkButton* _sender,
                                               gpointer self)
{
	image_editor_action_paste ((ImageEditor*) self);
}

static void
_image_editor_action_delete_gtk_button_clicked (GtkButton* _sender,
                                                gpointer self)
{
	image_editor_action_delete ((ImageEditor*) self);
}

static GtkBox*
image_editor_create_buttons (ImageEditor* self,
                             DrawArea* da,
                             ImageManager* im)
{
	Block24Data* _data24_;
	DrawArea* _tmp0_;
	ImageManager* _tmp1_;
	GtkButton* open = NULL;
	gchar* _tmp2_;
	GtkButton* _tmp3_ = NULL;
	GtkButton* paste = NULL;
	gchar* _tmp4_;
	GtkButton* _tmp5_ = NULL;
	GtkButton* del = NULL;
	gchar* _tmp6_;
	GtkButton* _tmp7_ = NULL;
	GtkButton* copy = NULL;
	gchar* _tmp8_;
	GtkButton* _tmp9_ = NULL;
	GtkButton* cut = NULL;
	gchar* _tmp10_;
	GtkButton* _tmp11_ = NULL;
	GtkButton* cancel = NULL;
	GtkButton* _tmp12_ = NULL;
	GtkButton* apply = NULL;
	GtkButton* _tmp13_ = NULL;
	GtkButton* _tmp14_;
	GtkBox* box = NULL;
	GtkBox* _tmp15_;
	GtkBox* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (da != NULL, NULL);
	g_return_val_if_fail (im != NULL, NULL);
	_data24_ = g_slice_new0 (Block24Data);
	_data24_->_ref_count_ = 1;
	_data24_->self = image_editor_ref (self);
	_tmp0_ = _g_object_ref0 (da);
	_g_object_unref0 (_data24_->da);
	_data24_->da = _tmp0_;
	_tmp1_ = _image_manager_ref0 (im);
	_image_manager_unref0 (_data24_->im);
	_data24_->im = _tmp1_;
	_tmp2_ = utils_tooltip_with_accel (_ ("Change Image"), "<Control>o");
	_tmp3_ = (GtkButton*) gtk_button_new_from_icon_name ("folder-open-symbolic");
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_START);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp3_, _tmp2_);
	_g_free0 (_tmp2_);
	g_object_ref_sink (_tmp3_);
	open = _tmp3_;
	_tmp4_ = utils_tooltip_with_accel (_ ("Paste Image from Clipboard"), "<Control>v");
	_tmp5_ = (GtkButton*) gtk_button_new_from_icon_name ("edit-paste-symbolic");
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_START);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp5_, _tmp4_);
	_g_free0 (_tmp4_);
	g_object_ref_sink (_tmp5_);
	paste = _tmp5_;
	_tmp6_ = utils_tooltip_with_accel (_ ("Remove Image"), "Delete");
	_tmp7_ = (GtkButton*) gtk_button_new_from_icon_name ("edit-delete-symbolic");
	gtk_widget_set_halign ((GtkWidget*) _tmp7_, GTK_ALIGN_START);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp7_, _tmp6_);
	_g_free0 (_tmp6_);
	g_object_ref_sink (_tmp7_);
	del = _tmp7_;
	_tmp8_ = utils_tooltip_with_accel (_ ("Copy Image to Clipboard"), "<Control>c");
	_tmp9_ = (GtkButton*) gtk_button_new_from_icon_name ("edit-copy-symbolic");
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_START);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp9_, _tmp8_);
	_g_free0 (_tmp8_);
	g_object_ref_sink (_tmp9_);
	copy = _tmp9_;
	_tmp10_ = utils_tooltip_with_accel (_ ("Cut Image to Clipboard"), "<Control>x");
	_tmp11_ = (GtkButton*) gtk_button_new_from_icon_name ("edit-cut-symbolic");
	gtk_widget_set_halign ((GtkWidget*) _tmp11_, GTK_ALIGN_START);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp11_, TRUE);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp11_, _tmp10_);
	_g_free0 (_tmp10_);
	g_object_ref_sink (_tmp11_);
	cut = _tmp11_;
	_tmp12_ = (GtkButton*) gtk_button_new_with_label (_ ("Cancel"));
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_END);
	g_object_ref_sink (_tmp12_);
	cancel = _tmp12_;
	_tmp13_ = (GtkButton*) gtk_button_new_with_label (_ ("Apply"));
	gtk_widget_set_halign ((GtkWidget*) _tmp13_, GTK_ALIGN_END);
	g_object_ref_sink (_tmp13_);
	apply = _tmp13_;
	_tmp14_ = _g_object_ref0 (paste);
	_g_object_unref0 (self->priv->_paste);
	self->priv->_paste = _tmp14_;
	g_signal_connect_data (open, "clicked", (GCallback) ___lambda102__gtk_button_clicked, block24_data_ref (_data24_), (GClosureNotify) block24_data_unref, 0);
	g_signal_connect (cancel, "clicked", (GCallback) _image_editor_action_cancel_gtk_button_clicked, self);
	g_signal_connect (apply, "clicked", (GCallback) _image_editor_action_apply_gtk_button_clicked, self);
	g_signal_connect (copy, "clicked", (GCallback) _image_editor_action_copy_gtk_button_clicked, self);
	g_signal_connect (cut, "clicked", (GCallback) _image_editor_action_cut_gtk_button_clicked, self);
	g_signal_connect (paste, "clicked", (GCallback) _image_editor_action_paste_gtk_button_clicked, self);
	g_signal_connect (del, "clicked", (GCallback) _image_editor_action_delete_gtk_button_clicked, self);
	_tmp15_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	g_object_ref_sink (_tmp15_);
	box = _tmp15_;
	gtk_box_append (box, (GtkWidget*) open);
	gtk_box_append (box, (GtkWidget*) paste);
	gtk_box_append (box, (GtkWidget*) del);
	gtk_box_append (box, (GtkWidget*) copy);
	gtk_box_append (box, (GtkWidget*) cut);
	gtk_box_append (box, (GtkWidget*) cancel);
	gtk_box_append (box, (GtkWidget*) apply);
	result = box;
	_g_object_unref0 (apply);
	_g_object_unref0 (cancel);
	_g_object_unref0 (cut);
	_g_object_unref0 (copy);
	_g_object_unref0 (del);
	_g_object_unref0 (paste);
	_g_object_unref0 (open);
	block24_data_unref (_data24_);
	_data24_ = NULL;
	return result;
}

static void
image_editor_set_cursor (ImageEditor* self,
                         const gchar* cursor_name)
{
	GdkCursor* cursor = NULL;
	GtkDrawingArea* _tmp0_;
	GdkCursor* _tmp1_;
	GdkCursor* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_da;
	_tmp1_ = gtk_widget_get_cursor ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	cursor = _tmp2_;
	if (cursor_name == NULL) {
		GtkDrawingArea* _tmp3_;
		_tmp3_ = self->priv->_da;
		gtk_widget_set_cursor ((GtkWidget*) _tmp3_, NULL);
	} else {
		gboolean _tmp4_ = FALSE;
		GdkCursor* _tmp5_;
		_tmp5_ = cursor;
		if (_tmp5_ == NULL) {
			_tmp4_ = TRUE;
		} else {
			GdkCursor* _tmp6_;
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			_tmp6_ = cursor;
			_tmp7_ = gdk_cursor_get_name (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp4_ = g_strcmp0 (_tmp8_, cursor_name) != 0;
		}
		if (_tmp4_) {
			GtkDrawingArea* _tmp9_;
			GdkCursor* _tmp10_;
			GdkCursor* _tmp11_;
			_tmp9_ = self->priv->_da;
			_tmp10_ = gdk_cursor_new_from_name (cursor_name, NULL);
			_tmp11_ = _tmp10_;
			gtk_widget_set_cursor ((GtkWidget*) _tmp9_, _tmp11_);
			_g_object_unref0 (_tmp11_);
		}
	}
	_g_object_unref0 (cursor);
}

static void
image_editor_draw_image (ImageEditor* self,
                         cairo_t* ctx)
{
	NodeImage* _tmp0_;
	GdkPixbuf* _tmp1_;
	GdkPixbuf* _tmp2_;
	GtkDrawingArea* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	GtkDrawingArea* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	NodeImage* _tmp9_;
	GdkPixbuf* _tmp10_;
	GdkPixbuf* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (ctx != NULL);
	cairo_scale (ctx, self->priv->_scale, self->priv->_scale);
	_tmp0_ = self->priv->_image;
	_tmp1_ = node_image_get_orig_pixbuf (_tmp0_);
	_tmp2_ = _tmp1_;
	gdk_cairo_set_source_pixbuf (ctx, _tmp2_, (gdouble) 0, (gdouble) 0);
	_g_object_unref0 (_tmp2_);
	cairo_paint (ctx);
	cairo_set_source_rgba (ctx, (gdouble) 0, (gdouble) 0, (gdouble) 0, 0.8);
	_tmp3_ = self->priv->_da;
	g_object_get ((GtkWidget*) _tmp3_, "width-request", &_tmp4_, NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->priv->_da;
	g_object_get ((GtkWidget*) _tmp6_, "height-request", &_tmp7_, NULL);
	_tmp8_ = _tmp7_;
	cairo_rectangle (ctx, (gdouble) 0, (gdouble) 0, (gdouble) _tmp5_, (gdouble) _tmp8_);
	cairo_fill (ctx);
	cairo_set_operator (ctx, CAIRO_OPERATOR_CLEAR);
	cairo_rectangle (ctx, (gdouble) ((gint) self->priv->_crop_x), (gdouble) ((gint) self->priv->_crop_y), (gdouble) ((gint) self->priv->_crop_w), (gdouble) ((gint) self->priv->_crop_h));
	cairo_fill (ctx);
	cairo_set_operator (ctx, CAIRO_OPERATOR_OVER);
	_tmp9_ = self->priv->_image;
	_tmp10_ = node_image_get_orig_pixbuf (_tmp9_);
	_tmp11_ = _tmp10_;
	gdk_cairo_set_source_pixbuf (ctx, _tmp11_, (gdouble) 0, (gdouble) 0);
	_g_object_unref0 (_tmp11_);
	cairo_rectangle (ctx, (gdouble) ((gint) self->priv->_crop_x), (gdouble) ((gint) self->priv->_crop_y), (gdouble) ((gint) self->priv->_crop_w), (gdouble) ((gint) self->priv->_crop_h));
	cairo_fill (ctx);
	cairo_set_line_width (ctx, (gdouble) 1);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp12_ = FALSE;
			_tmp12_ = TRUE;
			while (TRUE) {
				GdkRectangle* _tmp14_;
				gint _tmp14__length1;
				GdkRectangle _tmp15_;
				if (!_tmp12_) {
					gint _tmp13_;
					_tmp13_ = i;
					i = _tmp13_ + 1;
				}
				_tmp12_ = FALSE;
				if (!(i < 8)) {
					break;
				}
				_tmp14_ = self->priv->_crop_points;
				_tmp14__length1 = self->priv->_crop_points_length1;
				_tmp15_ = _tmp14_[i];
				image_editor_draw_crop_point (self, ctx, &_tmp15_);
			}
		}
	}
}

static void
image_editor_draw_crop_point (ImageEditor* self,
                              cairo_t* ctx,
                              GdkRectangle* crop)
{
	GdkRectangle _tmp0_;
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	GdkRectangle _tmp4_;
	GdkRectangle _tmp5_;
	GdkRectangle _tmp6_;
	GdkRectangle _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (crop != NULL);
	cairo_set_source_rgb (ctx, (gdouble) 1, (gdouble) 1, (gdouble) 1);
	_tmp0_ = *crop;
	_tmp1_ = *crop;
	_tmp2_ = *crop;
	_tmp3_ = *crop;
	cairo_rectangle (ctx, (gdouble) _tmp0_.x, (gdouble) _tmp1_.y, (gdouble) _tmp2_.width, (gdouble) _tmp3_.width);
	cairo_fill (ctx);
	cairo_set_source_rgb (ctx, (gdouble) 0, (gdouble) 0, (gdouble) 0);
	_tmp4_ = *crop;
	_tmp5_ = *crop;
	_tmp6_ = *crop;
	_tmp7_ = *crop;
	cairo_rectangle (ctx, (gdouble) _tmp4_.x, (gdouble) _tmp5_.y, (gdouble) _tmp6_.width, (gdouble) _tmp7_.width);
	cairo_stroke (ctx);
}

static void
image_editor_remove_image (ImageEditor* self,
                           ImageManager* im)
{
	NodeImage* orig_image = NULL;
	Node* _tmp0_;
	NodeImage* _tmp1_;
	NodeImage* _tmp2_;
	NodeImage* _tmp3_;
	Node* _tmp4_;
	GtkPopover* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (im != NULL);
	_tmp0_ = self->priv->_node;
	_tmp1_ = node_get_image (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _node_image_ref0 (_tmp2_);
	orig_image = _tmp3_;
	_tmp4_ = self->priv->_node;
	node_set_image (_tmp4_, im, NULL);
	g_signal_emit (self, image_editor_signals[IMAGE_EDITOR_CHANGED_SIGNAL], 0, orig_image);
	_tmp5_ = self->priv->_popover;
	gtk_popover_popdown (_tmp5_);
	_node_image_unref0 (orig_image);
}

static void
image_editor_set_image (ImageEditor* self,
                        ImageManager* im)
{
	NodeImage* orig_image = NULL;
	Node* _tmp0_;
	NodeImage* _tmp1_;
	NodeImage* _tmp2_;
	NodeImage* _tmp3_;
	NodeImage* _tmp4_;
	NodeImage* _tmp5_;
	NodeImage* _tmp6_;
	NodeImage* _tmp7_;
	NodeImage* _tmp8_;
	Node* _tmp9_;
	Style* _tmp10_;
	Style* _tmp11_;
	gint* _tmp12_;
	gint* _tmp13_;
	Node* _tmp14_;
	NodeImage* _tmp15_;
	GtkPopover* _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (im != NULL);
	_tmp0_ = self->priv->_node;
	_tmp1_ = node_get_image (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _node_image_ref0 (_tmp2_);
	orig_image = _tmp3_;
	_tmp4_ = self->priv->_image;
	node_image_set_crop_x (_tmp4_, (gint) self->priv->_crop_x);
	_tmp5_ = self->priv->_image;
	node_image_set_crop_y (_tmp5_, (gint) self->priv->_crop_y);
	_tmp6_ = self->priv->_image;
	node_image_set_crop_w (_tmp6_, (gint) self->priv->_crop_w);
	_tmp7_ = self->priv->_image;
	node_image_set_crop_h (_tmp7_, (gint) self->priv->_crop_h);
	_tmp8_ = self->priv->_image;
	_tmp9_ = self->priv->_node;
	_tmp10_ = node_get_style (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = style_get_node_width (_tmp11_);
	_tmp13_ = _tmp12_;
	node_image_set_width (_tmp8_, *_tmp13_);
	_tmp14_ = self->priv->_node;
	_tmp15_ = self->priv->_image;
	node_set_image (_tmp14_, im, _tmp15_);
	g_signal_emit (self, image_editor_signals[IMAGE_EDITOR_CHANGED_SIGNAL], 0, orig_image);
	_tmp16_ = self->priv->_popover;
	gtk_popover_popdown (_tmp16_);
	_node_image_unref0 (orig_image);
}

static gboolean
image_editor_image_pasteable (ImageEditor* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = minder_clipboard_image_pasteable ();
	return result;
}

static void
image_editor_update_ui (ImageEditor* self)
{
	GtkButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_paste;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, image_editor_image_pasteable (self));
}

static void
image_editor_action_copy (ImageEditor* self)
{
	gchar* fname = NULL;
	ImageManager* _tmp0_;
	Node* _tmp1_;
	NodeImage* _tmp2_;
	NodeImage* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_im;
	_tmp1_ = self->priv->_node;
	_tmp2_ = node_get_image (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = node_image_get_id (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = image_manager_get_file (_tmp0_, _tmp5_);
	fname = _tmp6_;
	_tmp7_ = fname;
	if (_tmp7_ != NULL) {
		{
			GdkPixbuf* buf = NULL;
			const gchar* _tmp8_;
			GdkPixbuf* _tmp9_;
			GdkPixbuf* _tmp10_;
			_tmp8_ = fname;
			_tmp9_ = gdk_pixbuf_new_from_file (_tmp8_, &_inner_error0_);
			buf = _tmp9_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp10_ = buf;
			minder_clipboard_copy_image (_tmp10_);
			image_editor_update_ui (self);
			_g_object_unref0 (buf);
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_inner_error0_);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (fname);
			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;
		}
	}
	_g_free0 (fname);
}

static void
image_editor_action_cut (ImageEditor* self)
{
	ImageManager* _tmp0_;
	g_return_if_fail (self != NULL);
	image_editor_action_copy (self);
	_tmp0_ = self->priv->_im;
	image_editor_remove_image (self, _tmp0_);
}

static Block25Data*
block25_data_ref (Block25Data* _data25_)
{
	g_atomic_int_inc (&_data25_->_ref_count_);
	return _data25_;
}

static void
block25_data_unref (void * _userdata_)
{
	Block25Data* _data25_;
	_data25_ = (Block25Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data25_->_ref_count_)) {
		ImageEditor* self;
		self = _data25_->self;
		_g_object_unref0 (_data25_->clipboard);
		_image_editor_unref0 (self);
		g_slice_free (Block25Data, _data25_);
	}
}

static void
___lambda104_ (Block25Data* _data25_,
               GObject* ob,
               GAsyncResult* res)
{
	ImageEditor* self;
	GError* _inner_error0_ = NULL;
	self = _data25_->self;
	g_return_if_fail (res != NULL);
	{
		GdkTexture* texture = NULL;
		GdkClipboard* _tmp0_;
		GdkTexture* _tmp1_;
		_tmp0_ = _data25_->clipboard;
		_tmp1_ = gdk_clipboard_read_texture_finish (_tmp0_, res, &_inner_error0_);
		texture = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (texture != NULL) {
			GdkPixbuf* buf = NULL;
			GdkPixbuf* _tmp2_;
			NodeImage* image = NULL;
			ImageManager* _tmp3_;
			GdkPixbuf* _tmp4_;
			Node* _tmp5_;
			Style* _tmp6_;
			Style* _tmp7_;
			gint* _tmp8_;
			gint* _tmp9_;
			NodeImage* _tmp10_;
			NodeImage* _tmp11_;
			NodeImage* _tmp12_;
			GtkDrawingArea* _tmp13_;
			_tmp2_ = utils_texture_to_pixbuf (texture);
			buf = _tmp2_;
			_tmp3_ = self->priv->_im;
			_tmp4_ = buf;
			_tmp5_ = self->priv->_node;
			_tmp6_ = node_get_style (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = style_get_node_width (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = node_image_new_from_pixbuf (_tmp3_, _tmp4_, *_tmp9_);
			image = _tmp10_;
			_tmp11_ = image;
			_tmp12_ = _node_image_ref0 (_tmp11_);
			_node_image_unref0 (self->priv->_image);
			self->priv->_image = _tmp12_;
			_tmp13_ = self->priv->_da;
			gtk_widget_queue_draw ((GtkWidget*) _tmp13_);
			_node_image_unref0 (image);
			_g_object_unref0 (buf);
		}
		_g_object_unref0 (texture);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
____lambda104__gasync_ready_callback (GObject* source_object,
                                      GAsyncResult* res,
                                      gpointer self)
{
	___lambda104_ (self, source_object, res);
	block25_data_unref (self);
}

static void
image_editor_action_paste (ImageEditor* self)
{
	g_return_if_fail (self != NULL);
	if (image_editor_image_pasteable (self)) {
		Block25Data* _data25_;
		GdkDisplay* _tmp0_;
		GdkClipboard* _tmp1_;
		GdkClipboard* _tmp2_;
		GdkClipboard* _tmp3_;
		_data25_ = g_slice_new0 (Block25Data);
		_data25_->_ref_count_ = 1;
		_data25_->self = image_editor_ref (self);
		_tmp0_ = gdk_display_get_default ();
		_tmp1_ = gdk_display_get_clipboard (_tmp0_);
		_tmp2_ = _g_object_ref0 (_tmp1_);
		_data25_->clipboard = _tmp2_;
		_tmp3_ = _data25_->clipboard;
		gdk_clipboard_read_texture_async (_tmp3_, NULL, ____lambda104__gasync_ready_callback, block25_data_ref (_data25_));
		block25_data_unref (_data25_);
		_data25_ = NULL;
	} else {
		image_editor_update_ui (self);
	}
}

static void
image_editor_action_delete (ImageEditor* self)
{
	ImageManager* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_im;
	image_editor_remove_image (self, _tmp0_);
}

static void
image_editor_action_cancel (ImageEditor* self)
{
	GtkPopover* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_popover;
	gtk_popover_popdown (_tmp0_);
}

static void
image_editor_action_apply (ImageEditor* self)
{
	ImageManager* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_im;
	image_editor_set_image (self, _tmp0_);
}

static void
g_cclosure_user_marshal_VOID__NODE_IMAGE (GClosure * closure,
                                          GValue * return_value,
                                          guint n_param_values,
                                          const GValue * param_values,
                                          gpointer invocation_hint,
                                          gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__NODE_IMAGE) (gpointer data1, gpointer arg_1, gpointer data2);
	register GMarshalFunc_VOID__NODE_IMAGE callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	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_VOID__NODE_IMAGE) (marshal_data ? marshal_data : cc->callback);
	callback (data1, value_get_node_image (param_values + 1), data2);
}

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

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

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

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

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

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

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

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

void
value_set_image_editor (GValue* value,
                        gpointer v_object)
{
	ImageEditor * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_IMAGE_EDITOR));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_IMAGE_EDITOR));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		image_editor_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		image_editor_unref (old);
	}
}

void
value_take_image_editor (GValue* value,
                         gpointer v_object)
{
	ImageEditor * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_IMAGE_EDITOR));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_IMAGE_EDITOR));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		image_editor_unref (old);
	}
}

static void
image_editor_class_init (ImageEditorClass * klass,
                         gpointer klass_data)
{
	image_editor_parent_class = g_type_class_peek_parent (klass);
	((ImageEditorClass *) klass)->finalize = image_editor_finalize;
	g_type_class_adjust_private_offset (klass, &ImageEditor_private_offset);
	image_editor_signals[IMAGE_EDITOR_CHANGED_SIGNAL] = g_signal_new ("changed", TYPE_IMAGE_EDITOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__NODE_IMAGE, G_TYPE_NONE, 1, TYPE_NODE_IMAGE);
}

static void
image_editor_instance_init (ImageEditor * self,
                            gpointer klass)
{
	self->priv = image_editor_get_instance_private (self);
	self->priv->_crop_target = -1;
	self->ref_count = 1;
}

static void
image_editor_finalize (ImageEditor * obj)
{
	ImageEditor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_IMAGE_EDITOR, ImageEditor);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->_popover);
	_image_manager_unref0 (self->priv->_im);
	_g_object_unref0 (self->priv->_da);
	_g_object_unref0 (self->priv->_node);
	_node_image_unref0 (self->priv->_image);
	_g_object_unref0 (self->priv->_paste);
	self->priv->_crop_points = (g_free (self->priv->_crop_points), NULL);
	self->priv->_crop_cursors = (_vala_array_free (self->priv->_crop_cursors, self->priv->_crop_cursors_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (self->priv->_status_cursor);
	_g_object_unref0 (self->priv->_status_crop);
}

static GType
image_editor_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_image_editor_init, value_image_editor_free_value, value_image_editor_copy_value, value_image_editor_peek_pointer, "p", value_image_editor_collect_value, "p", value_image_editor_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (ImageEditorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) image_editor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ImageEditor), 0, (GInstanceInitFunc) image_editor_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType image_editor_type_id;
	image_editor_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ImageEditor", &g_define_type_info, &g_define_type_fundamental_info, 0);
	ImageEditor_private_offset = g_type_add_instance_private (image_editor_type_id, sizeof (ImageEditorPrivate));
	return image_editor_type_id;
}

GType
image_editor_get_type (void)
{
	static volatile gsize image_editor_type_id__once = 0;
	if (g_once_init_enter (&image_editor_type_id__once)) {
		GType image_editor_type_id;
		image_editor_type_id = image_editor_get_type_once ();
		g_once_init_leave (&image_editor_type_id__once, image_editor_type_id);
	}
	return image_editor_type_id__once;
}

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

void
image_editor_unref (gpointer instance)
{
	ImageEditor * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		IMAGE_EDITOR_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

