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

/*
* Copyright (c) 2009-2013 Yorba Foundation
*               2018 elementary LLC. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
*/

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

#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

enum  {
	EDITING_HOST_PAGE_0_PROPERTY,
	EDITING_HOST_PAGE_SOURCES_PROPERTY,
	EDITING_HOST_PAGE_NUM_PROPERTIES
};
static GParamSpec* editing_host_page_properties[EDITING_HOST_PAGE_NUM_PROPERTIES];
#define _data_collection_unref0(var) ((var == NULL) ? NULL : (var = (data_collection_unref (var), NULL)))
typedef enum  {
	EDITING_HOST_PAGE_TARGET_TYPE_GNOME_COPIED_FILES,
	EDITING_HOST_PAGE_TARGET_TYPE_IMAGE,
	EDITING_HOST_PAGE_TARGET_TYPE_TEXT_URI_LIST,
	EDITING_HOST_PAGE_TARGET_TYPE_TEXT
} EditingHostPageTargetType;

#define EDITING_HOST_PAGE_TYPE_TARGET_TYPE (editing_host_page_target_type_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _drag_and_drop_handler_unref0(var) ((var == NULL) ? NULL : (var = (drag_and_drop_handler_unref (var), NULL)))
typedef struct _Block11Data Block11Data;
typedef struct _Block12Data Block12Data;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define EDITING_HOST_PAGE_TYPE_EDITING_HOST_CANVAS (editing_host_page_editing_host_canvas_get_type ())
#define EDITING_HOST_PAGE_EDITING_HOST_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDITING_HOST_PAGE_TYPE_EDITING_HOST_CANVAS, EditingHostPageEditingHostCanvas))
#define EDITING_HOST_PAGE_EDITING_HOST_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDITING_HOST_PAGE_TYPE_EDITING_HOST_CANVAS, EditingHostPageEditingHostCanvasClass))
#define EDITING_HOST_PAGE_IS_EDITING_HOST_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDITING_HOST_PAGE_TYPE_EDITING_HOST_CANVAS))
#define EDITING_HOST_PAGE_IS_EDITING_HOST_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDITING_HOST_PAGE_TYPE_EDITING_HOST_CANVAS))
#define EDITING_HOST_PAGE_EDITING_HOST_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDITING_HOST_PAGE_TYPE_EDITING_HOST_CANVAS, EditingHostPageEditingHostCanvasClass))

typedef struct _EditingHostPageEditingHostCanvas EditingHostPageEditingHostCanvas;
typedef struct _EditingHostPageEditingHostCanvasClass EditingHostPageEditingHostCanvasClass;
#define _command_manager_unref0(var) ((var == NULL) ? NULL : (var = (command_manager_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _media_metadata_unref0(var) ((var == NULL) ? NULL : (var = (media_metadata_unref (var), NULL)))
#define _scaling_free0(var) ((var == NULL) ? NULL : (var = (scaling_free (var), NULL)))
#define _pixel_transformation_bundle_unref0(var) ((var == NULL) ? NULL : (var = (pixel_transformation_bundle_unref (var), NULL)))
typedef struct _EditingHostPageEditingHostCanvasPrivate EditingHostPageEditingHostCanvasPrivate;
enum  {
	EDITING_HOST_PAGE_EDITING_HOST_CANVAS_0_PROPERTY,
	EDITING_HOST_PAGE_EDITING_HOST_CANVAS_NUM_PROPERTIES
};
static GParamSpec* editing_host_page_editing_host_canvas_properties[EDITING_HOST_PAGE_EDITING_HOST_CANVAS_NUM_PROPERTIES];
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _EditingHostPagePrivate {
	ViewCollection* parent_view;
	GdkPixbuf* swapped;
	gboolean pixbuf_dirty;
	GtkButton* flip_button;
	GtkToggleButton* crop_button;
	GtkToggleButton* redeye_button;
	GtkToggleButton* adjust_button;
	GtkToggleButton* straighten_button;
	SliderAssembly* zoom_assembly;
	GtkButton* prev_button;
	GtkButton* next_button;
	EditingToolsEditingTool* current_tool;
	GtkToggleButton* current_editing_toggle;
	GdkPixbuf* cancel_editing_pixbuf;
	gboolean photo_missing;
	PixbufCache* cache;
	PixbufCache* master_cache;
	DragAndDropHandler* dnd_handler;
	GdkPoint zoom_pan_start_point;
	gboolean is_pan_in_progress;
	gdouble saved_slider_val;
	ZoomBuffer* zoom_buffer;
	GeeHashMap* last_locations;
	SourceCollection* _sources;
	gboolean zooming;
};

struct _Block11Data {
	int _ref_count_;
	EditingHostPage* self;
	GtkAction* zoom_fit_action;
	LibraryWindow* app;
};

struct _Block12Data {
	int _ref_count_;
	EditingHostPage* self;
	gdouble interp;
};

struct _EditingHostPageEditingHostCanvas {
	EditingToolsPhotoCanvas parent_instance;
	EditingHostPageEditingHostCanvasPrivate * priv;
};

struct _EditingHostPageEditingHostCanvasClass {
	EditingToolsPhotoCanvasClass parent_class;
};

struct _EditingHostPageEditingHostCanvasPrivate {
	EditingHostPage* host_page;
};

static gint EditingHostPage_private_offset;
static gpointer editing_host_page_parent_class = NULL;
static Photo* editing_host_page_copied_photo;
static Photo* editing_host_page_copied_photo = NULL;
static Scaling* editing_host_page_copied_scaling;
static Scaling* editing_host_page_copied_scaling = NULL;
static GtkClipboard* editing_host_page_clipboard;
static GtkClipboard* editing_host_page_clipboard = NULL;
static gint EditingHostPageEditingHostCanvas_private_offset;
static gpointer editing_host_page_editing_host_canvas_parent_class = NULL;

static void editing_host_page_on_photos_altered (EditingHostPage* self,
                                          GeeMap* map);
static void _editing_host_page_on_photos_altered_data_collection_items_altered (DataCollection* _sender,
                                                                         GeeMap* items,
                                                                         gpointer self);
static void editing_host_page_on_view_contents_ordering_altered (EditingHostPage* self);
static void _editing_host_page_on_view_contents_ordering_altered_data_collection_contents_altered (DataCollection* _sender,
                                                                                            GeeIterable* added,
                                                                                            GeeIterable* removed,
                                                                                            gpointer self);
static void _editing_host_page_on_view_contents_ordering_altered_data_collection_ordering_changed (DataCollection* _sender,
                                                                                            gpointer self);
static GType editing_host_page_target_type_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void editing_host_page_real_add_toolbar_widgets (Page* base,
                                                 GtkActionBar* toolbar);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
static void _editing_host_page_on_rotate_clockwise_gtk_button_clicked (GtkButton* _sender,
                                                                gpointer self);
static void _editing_host_page_on_flip_horizontally_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self);
static void editing_host_page_on_crop_toggled (EditingHostPage* self);
static void _editing_host_page_on_crop_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                   gpointer self);
static void editing_host_page_on_straighten_toggled (EditingHostPage* self);
static void _editing_host_page_on_straighten_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                         gpointer self);
static void editing_host_page_on_redeye_toggled (EditingHostPage* self);
static void _editing_host_page_on_redeye_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                     gpointer self);
static void editing_host_page_on_adjust_toggled (EditingHostPage* self);
static void _editing_host_page_on_adjust_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                     gpointer self);
static void _editing_host_page_on_enhance_gtk_button_clicked (GtkButton* _sender,
                                                       gpointer self);
static void __lambda50_ (Block11Data* _data11_);
static void ___lambda50__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda51_ (EditingHostPage* self);
static void ___lambda51__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void editing_host_page_on_zoom_assembly_value_changed (EditingHostPage* self);
static void _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed (SliderAssembly* _sender,
                                                                                      gpointer self);
static void _single_photo_page_on_previous_photo_gtk_button_clicked (GtkButton* _sender,
                                                              gpointer self);
static void _single_photo_page_on_next_photo_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self);
static void ___lambda52_ (Block11Data* _data11_);
static void ____lambda52__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void editing_host_page_update_cursor_for_zoom_context (EditingHostPage* self);
static void editing_host_page_get_cursor_wrt_viewport (EditingHostPage* self,
                                                GdkEventScroll* event,
                                                GdkPoint* result);
static void editing_host_page_get_cursor_wrt_viewport_center (EditingHostPage* self,
                                                       GdkEventScroll* event,
                                                       GdkPoint* result);
static void editing_host_page_get_iso_pixel_under_cursor (EditingHostPage* self,
                                                   GdkEventScroll* event,
                                                   GdkPoint* result);
static gdouble editing_host_page_snap_interpolation_factor (EditingHostPage* self,
                                                     gdouble interp);
static gdouble editing_host_page_adjust_interpolation_factor (EditingHostPage* self,
                                                       gdouble adjustment);
static void editing_host_page_zoom_about_event_cursor_point (EditingHostPage* self,
                                                      GdkEventScroll* event,
                                                      gdouble zoom_increment);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
static gboolean __lambda53_ (Block12Data* _data12_);
static gboolean ___lambda53__gsource_func (gpointer self);
static gboolean editing_host_page_real_on_zoom_assembly_key_press (EditingHostPage* self,
                                                            GdkEventKey* event);
static void editing_host_page_real_on_increase_size (EditingHostPage* self);
static void editing_host_page_real_on_decrease_size (EditingHostPage* self);
static void editing_host_page_real_save_zoom_state (SinglePhotoPage* base);
static ZoomBuffer* editing_host_page_real_get_zoom_buffer (SinglePhotoPage* base);
static gboolean editing_host_page_real_on_mousewheel_up (Page* base,
                                                  GdkEventScroll* event);
static gboolean editing_host_page_real_on_mousewheel_down (Page* base,
                                                    GdkEventScroll* event);
static void editing_host_page_real_restore_zoom_state (SinglePhotoPage* base);
static gboolean editing_host_page_real_is_zoom_supported (SinglePhotoPage* base);
static void editing_host_page_real_set_container (Page* base,
                                           GtkWindow* container);
static void editing_host_page_real_photo_changing (EditingHostPage* self,
                                            Photo* new_photo);
static void editing_host_page_set_photo (EditingHostPage* self,
                                  Photo* photo);
static void editing_host_page_real_realize (GtkWidget* base);
static void editing_host_page_rebuild_caches (EditingHostPage* self,
                                       const gchar* caller);
static void editing_host_page_real_switched_to (Page* base);
static void editing_host_page_replace_photo (EditingHostPage* self,
                                      Photo* new_photo);
static void editing_host_page_real_switching_from (Page* base);
static void editing_host_page_deactivate_tool (EditingHostPage* self,
                                        Command* command,
                                        GdkPixbuf* new_pixbuf,
                                        Dimensions* new_max_dim,
                                        gboolean needs_improvement);
static void editing_host_page_real_switching_to_fullscreen (Page* base,
                                                     FullscreenWindow* fsw);
static void editing_host_page_on_selection_changed (EditingHostPage* self,
                                             GeeIterable* selected);
static void _editing_host_page_on_selection_changed_view_collection_items_selected (ViewCollection* _sender,
                                                                             GeeIterable* selected,
                                                                             gpointer self);
static void editing_host_page_real_returning_from_fullscreen (Page* base,
                                                       FullscreenWindow* fsw);
static void editing_host_page_on_pixbuf_fetched (EditingHostPage* self,
                                          Photo* photo,
                                          GdkPixbuf* pixbuf,
                                          GError* err);
static void _editing_host_page_on_pixbuf_fetched_pixbuf_cache_fetched (PixbufCache* _sender,
                                                                Photo* photo,
                                                                GdkPixbuf* pixbuf,
                                                                GError* err,
                                                                gpointer self);
static gboolean editing_host_page_master_cache_filter (EditingHostPage* self,
                                                Photo* photo);
static gboolean _editing_host_page_master_cache_filter_pixbuf_cache_cache_filter (Photo* photo,
                                                                           gpointer self);
static void editing_host_page_refresh_caches (EditingHostPage* self,
                                       const gchar* caller);
static void editing_host_page_prefetch_neighbors (EditingHostPage* self,
                                           ViewCollection* controller,
                                           Photo* photo);
static void editing_host_page_cancel_prefetch_neighbors (EditingHostPage* self,
                                                  ViewCollection* old_controller,
                                                  Photo* old_photo,
                                                  ViewCollection* new_controller,
                                                  Photo* new_photo);
static DataView* editing_host_page_real_create_photo_view (EditingHostPage* self,
                                                    DataSource* source);
static gboolean editing_host_page_is_photo (EditingHostPage* self,
                                     DataSource* source);
static DataView* _editing_host_page_create_photo_view_create_view (DataSource* source,
                                                            gpointer self);
static gboolean _editing_host_page_is_photo_create_view_predicate (DataSource* source,
                                                            gpointer self);
static void editing_host_page_real_update_ui (EditingHostPage* self,
                                       gboolean missing);
static void editing_host_page_real_notify_photo_backing_missing (EditingHostPage* self,
                                                          Photo* photo,
                                                          gboolean missing);
static void editing_host_page_draw_message (EditingHostPage* self,
                                     const gchar* message);
static gboolean editing_host_page_real_confirm_replace_photo (EditingHostPage* self,
                                                       Photo* old_photo,
                                                       Photo* new_photo);
static GdkPixbuf* editing_host_page_get_zoom_pixbuf (EditingHostPage* self,
                                              Photo* new_photo);
static void editing_host_page_quick_update_pixbuf (EditingHostPage* self);
static void editing_host_page_real_cancel_zoom (SinglePhotoPage* base);
static gboolean editing_host_page_update_pixbuf (EditingHostPage* self);
static void editing_host_page_real_on_resize_finished (Page* base,
                                                GdkRectangle* rect);
static void editing_host_page_on_viewport_resized (EditingHostPage* self);
static void editing_host_page_real_update_actions (Page* base,
                                            gint selected_count,
                                            gint count);
static gboolean editing_host_page_real_on_shift_pressed (Page* base,
                                                  GdkEventKey* event);
static void editing_host_page_swap_in_original (EditingHostPage* self);
static gboolean editing_host_page_real_on_shift_released (Page* base,
                                                   GdkEventKey* event);
static void editing_host_page_swap_out_original (EditingHostPage* self);
static gboolean editing_host_page_real_on_alt_pressed (Page* base,
                                                GdkEventKey* event);
static gboolean editing_host_page_real_on_alt_released (Page* base,
                                                 GdkEventKey* event);
static void editing_host_page_activate_tool (EditingHostPage* self,
                                      EditingToolsEditingTool* tool);
static EditingHostPageEditingHostCanvas* editing_host_page_editing_host_canvas_new (EditingHostPage* host_page);
static EditingHostPageEditingHostCanvas* editing_host_page_editing_host_canvas_construct (GType object_type,
                                                                                   EditingHostPage* host_page);
static GType editing_host_page_editing_host_canvas_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void editing_host_page_place_tool_window (EditingHostPage* self);
static void editing_host_page_on_tool_activated (EditingHostPage* self);
static void _editing_host_page_on_tool_activated_editing_tools_editing_tool_activated (EditingToolsEditingTool* _sender,
                                                                                gpointer self);
static void editing_host_page_on_tool_deactivated (EditingHostPage* self);
static void _editing_host_page_on_tool_deactivated_editing_tools_editing_tool_deactivated (EditingToolsEditingTool* _sender,
                                                                                    gpointer self);
static void editing_host_page_on_tool_applied (EditingHostPage* self,
                                        Command* command,
                                        GdkPixbuf* new_pixbuf,
                                        Dimensions* new_max_dim,
                                        gboolean needs_improvement);
static void _editing_host_page_on_tool_applied_editing_tools_editing_tool_applied (EditingToolsEditingTool* _sender,
                                                                            Command* command,
                                                                            GdkPixbuf* new_pixbuf,
                                                                            Dimensions* new_max_dim,
                                                                            gboolean needs_improvement,
                                                                            gpointer self);
static void editing_host_page_on_tool_cancelled (EditingHostPage* self);
static void _editing_host_page_on_tool_cancelled_editing_tools_editing_tool_cancelled (EditingToolsEditingTool* _sender,
                                                                                gpointer self);
static void editing_host_page_on_tool_aborted (EditingHostPage* self);
static void _editing_host_page_on_tool_aborted_editing_tools_editing_tool_aborted (EditingToolsEditingTool* _sender,
                                                                            gpointer self);
static gboolean _editing_host_page_update_pixbuf_gsource_func (gpointer self);
static gboolean editing_host_page_real_on_double_click (EditingHostPage* self,
                                                 GdkEventButton* event);
static gboolean editing_host_page_real_on_left_click (Page* base,
                                               GdkEventButton* event);
static gboolean editing_host_page_real_on_left_released (Page* base,
                                                  GdkEventButton* event);
static gboolean editing_host_page_real_on_right_click (Page* base,
                                                GdkEventButton* event);
static gboolean editing_host_page_on_fetch_original (EditingHostPage* self);
static gboolean _editing_host_page_on_fetch_original_gsource_func (gpointer self);
static gboolean editing_host_page_is_panning_possible (EditingHostPage* self);
static gboolean editing_host_page_real_on_motion (Page* base,
                                           GdkEventMotion* event,
                                           gint x,
                                           gint y,
                                           GdkModifierType mask);
static gboolean editing_host_page_real_on_leave_notify_event (Page* base);
static void editing_host_page_real_on_move_finished (Page* base,
                                              GdkRectangle* rect);
static gboolean editing_host_page_on_keyboard_pan_event (EditingHostPage* self,
                                                  GdkEventKey* event);
static gboolean editing_host_page_real_key_press_event (GtkWidget* base,
                                                 GdkEventKey* event);
static void editing_host_page_real_new_surface (SinglePhotoPage* base,
                                         cairo_t* default_ctx,
                                         Dimensions* dim);
static void editing_host_page_real_updated_pixbuf (SinglePhotoPage* base,
                                            GdkPixbuf* pixbuf,
                                            SinglePhotoPageUpdateReason reason,
                                            Dimensions* old_dim);
static GdkPixbuf* editing_host_page_real_get_bottom_left_trinket (EditingHostPage* self,
                                                           gint scale);
static GdkPixbuf* editing_host_page_real_get_top_left_trinket (EditingHostPage* self,
                                                        gint scale);
static GdkPixbuf* editing_host_page_real_get_top_right_trinket (EditingHostPage* self,
                                                         gint scale);
static GdkPixbuf* editing_host_page_real_get_bottom_right_trinket (EditingHostPage* self,
                                                            gint scale);
static void editing_host_page_real_paint (SinglePhotoPage* base,
                                   cairo_t* ctx,
                                   Dimensions* ctx_dim);
static void editing_host_page_rotate (EditingHostPage* self,
                               Rotation rotation,
                               const gchar* name,
                               const gchar* description);
static void _editing_host_page_get_image_data_for_clipboard_gtk_clipboard_get_func (GtkClipboard* clipboard,
                                                                             GtkSelectionData* selection_data,
                                                                             guint info,
                                                                             void* user_data_or_owner);
static void _editing_host_page_clear_data_for_clipboard_gtk_clipboard_clear_func (GtkClipboard* clipboard,
                                                                           void* user_data_or_owner);
static void _editing_host_page_get_metadata_for_clipboard_gtk_clipboard_get_func (GtkClipboard* clipboard,
                                                                           GtkSelectionData* selection_data,
                                                                           guint info,
                                                                           void* user_data_or_owner);
static gboolean editing_host_page_real_on_ctrl_pressed (Page* base,
                                                 GdkEventKey* event);
static void _editing_host_page_on_rotate_counterclockwise_gtk_button_clicked (GtkButton* _sender,
                                                                       gpointer self);
static void _editing_host_page_on_flip_vertically_gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self);
static gboolean editing_host_page_real_on_ctrl_released (Page* base,
                                                  GdkEventKey* event);
static EditingToolsEditingTool* _editing_tools_straighten_tool_factory_editing_tools_editing_tool_factory (void);
static EditingToolsEditingTool* _editing_tools_crop_tool_factory_editing_tools_editing_tool_factory (void);
static EditingToolsEditingTool* _editing_tools_redeye_tool_factory_editing_tools_editing_tool_factory (void);
static EditingToolsEditingTool* _editing_tools_adjust_tool_factory_editing_tools_editing_tool_factory (void);
static void editing_host_page_real_on_next_photo (SinglePhotoPage* base);
static void editing_host_page_real_on_previous_photo (SinglePhotoPage* base);
static void editing_host_page_editing_host_canvas_real_repaint (EditingToolsPhotoCanvas* base);
static GtkStyleContext* editing_host_page_editing_host_canvas_real_get_style_context (EditingToolsPhotoCanvas* base);
static void editing_host_page_editing_host_canvas_finalize (GObject * obj);
static GType editing_host_page_editing_host_canvas_get_type_once (void);
static GObject * editing_host_page_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static void _editing_host_page_on_viewport_resized_gtk_widget_size_allocate (GtkWidget* _sender,
                                                                      GtkAllocation* allocation,
                                                                      gpointer self);
static void editing_host_page_finalize (GObject * obj);
static GType editing_host_page_get_type_once (void);
static void _vala_editing_host_page_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_editing_host_page_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);
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 const GtkTargetEntry EDITING_HOST_PAGE_COPY_TARGETS[4] = {{"image/png", (guint) GTK_TARGET_OTHER_APP, (guint) EDITING_HOST_PAGE_TARGET_TYPE_IMAGE}, {"x-special/gnome-copied-files", (guint) GTK_TARGET_OTHER_APP, (guint) EDITING_HOST_PAGE_TARGET_TYPE_GNOME_COPIED_FILES}, {"text/uri-list", (guint) GTK_TARGET_OTHER_APP, (guint) EDITING_HOST_PAGE_TARGET_TYPE_TEXT_URI_LIST}, {"UTF8_STRING", (guint) GTK_TARGET_OTHER_APP, (guint) EDITING_HOST_PAGE_TARGET_TYPE_TEXT}};

static inline gpointer
editing_host_page_get_instance_private (EditingHostPage* self)
{
	return G_STRUCT_MEMBER_P (self, EditingHostPage_private_offset);
}

static void
_editing_host_page_on_photos_altered_data_collection_items_altered (DataCollection* _sender,
                                                                    GeeMap* items,
                                                                    gpointer self)
{
	editing_host_page_on_photos_altered ((EditingHostPage*) self, items);
}

static void
_editing_host_page_on_view_contents_ordering_altered_data_collection_contents_altered (DataCollection* _sender,
                                                                                       GeeIterable* added,
                                                                                       GeeIterable* removed,
                                                                                       gpointer self)
{
	editing_host_page_on_view_contents_ordering_altered ((EditingHostPage*) self);
}

static void
_editing_host_page_on_view_contents_ordering_altered_data_collection_ordering_changed (DataCollection* _sender,
                                                                                       gpointer self)
{
	editing_host_page_on_view_contents_ordering_altered ((EditingHostPage*) self);
}

static GType
editing_host_page_target_type_get_type_once (void)
{
	static const GEnumValue values[] = {{EDITING_HOST_PAGE_TARGET_TYPE_GNOME_COPIED_FILES, "EDITING_HOST_PAGE_TARGET_TYPE_GNOME_COPIED_FILES", "gnome-copied-files"}, {EDITING_HOST_PAGE_TARGET_TYPE_IMAGE, "EDITING_HOST_PAGE_TARGET_TYPE_IMAGE", "image"}, {EDITING_HOST_PAGE_TARGET_TYPE_TEXT_URI_LIST, "EDITING_HOST_PAGE_TARGET_TYPE_TEXT_URI_LIST", "text-uri-list"}, {EDITING_HOST_PAGE_TARGET_TYPE_TEXT, "EDITING_HOST_PAGE_TARGET_TYPE_TEXT", "text"}, {0, NULL, NULL}};
	GType editing_host_page_target_type_type_id;
	editing_host_page_target_type_type_id = g_enum_register_static ("EditingHostPageTargetType", values);
	return editing_host_page_target_type_type_id;
}

static GType
editing_host_page_target_type_get_type (void)
{
	static volatile gsize editing_host_page_target_type_type_id__once = 0;
	if (g_once_init_enter (&editing_host_page_target_type_type_id__once)) {
		GType editing_host_page_target_type_type_id;
		editing_host_page_target_type_type_id = editing_host_page_target_type_get_type_once ();
		g_once_init_leave (&editing_host_page_target_type_type_id__once, editing_host_page_target_type_type_id);
	}
	return editing_host_page_target_type_type_id__once;
}

EditingHostPage*
editing_host_page_construct (GType object_type,
                             SourceCollection* sources,
                             const gchar* page_name)
{
	EditingHostPage * self = NULL;
	g_return_val_if_fail (sources != NULL, NULL);
	g_return_val_if_fail (page_name != NULL, NULL);
	self = (EditingHostPage*) g_object_new (object_type, "page-name", page_name, "scale-up-to-viewport", FALSE, "sources", sources, NULL);
	return self;
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		EditingHostPage* self;
		self = _data11_->self;
		_g_object_unref0 (_data11_->app);
		_g_object_unref0 (_data11_->zoom_fit_action);
		_g_object_unref0 (self);
		g_slice_free (Block11Data, _data11_);
	}
}

static void
_editing_host_page_on_rotate_clockwise_gtk_button_clicked (GtkButton* _sender,
                                                           gpointer self)
{
	editing_host_page_on_rotate_clockwise ((EditingHostPage*) self);
}

static void
_editing_host_page_on_flip_horizontally_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self)
{
	editing_host_page_on_flip_horizontally ((EditingHostPage*) self);
}

static void
_editing_host_page_on_crop_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                              gpointer self)
{
	editing_host_page_on_crop_toggled ((EditingHostPage*) self);
}

static void
_editing_host_page_on_straighten_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                    gpointer self)
{
	editing_host_page_on_straighten_toggled ((EditingHostPage*) self);
}

static void
_editing_host_page_on_redeye_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                gpointer self)
{
	editing_host_page_on_redeye_toggled ((EditingHostPage*) self);
}

static void
_editing_host_page_on_adjust_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                gpointer self)
{
	editing_host_page_on_adjust_toggled ((EditingHostPage*) self);
}

static void
_editing_host_page_on_enhance_gtk_button_clicked (GtkButton* _sender,
                                                  gpointer self)
{
	editing_host_page_on_enhance ((EditingHostPage*) self);
}

static void
__lambda50_ (Block11Data* _data11_)
{
	EditingHostPage* self;
	GtkAction* _tmp0_;
	self = _data11_->self;
	_tmp0_ = _data11_->zoom_fit_action;
	gtk_action_activate (_tmp0_);
}

static void
___lambda50__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda50_ (self);
}

static void
__lambda51_ (EditingHostPage* self)
{
	editing_host_page_snap_zoom_to_isomorphic (self);
}

static void
___lambda51__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda51_ ((EditingHostPage*) self);
}

static void
_editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed (SliderAssembly* _sender,
                                                                                 gpointer self)
{
	editing_host_page_on_zoom_assembly_value_changed ((EditingHostPage*) self);
}

static void
_single_photo_page_on_previous_photo_gtk_button_clicked (GtkButton* _sender,
                                                         gpointer self)
{
	single_photo_page_on_previous_photo ((SinglePhotoPage*) self);
}

static void
_single_photo_page_on_next_photo_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self)
{
	single_photo_page_on_next_photo ((SinglePhotoPage*) self);
}

static void
___lambda52_ (Block11Data* _data11_)
{
	EditingHostPage* self;
	LibraryWindow* _tmp0_;
	LibraryWindow* _tmp1_;
	LibraryWindow* _tmp2_;
	self = _data11_->self;
	_tmp0_ = _data11_->app;
	_tmp1_ = _data11_->app;
	library_window_set_metadata_sidebar_visible (_tmp0_, !library_window_is_metadata_sidebar_visible (_tmp1_));
	_tmp2_ = _data11_->app;
	page_update_sidebar_action ((Page*) self, !library_window_is_metadata_sidebar_visible (_tmp2_));
}

static void
____lambda52__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	___lambda52_ (self);
}

static void
editing_host_page_real_add_toolbar_widgets (Page* base,
                                            GtkActionBar* toolbar)
{
	EditingHostPage * self;
	Block11Data* _data11_;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	GtkToggleButton* _tmp6_;
	GtkToggleButton* _tmp7_;
	GtkImage* _tmp8_;
	GtkImage* _tmp9_;
	GtkToggleButton* _tmp10_;
	GtkToggleButton* _tmp11_;
	GtkToggleButton* _tmp12_;
	GtkToggleButton* _tmp13_;
	GtkImage* _tmp14_;
	GtkImage* _tmp15_;
	GtkToggleButton* _tmp16_;
	GtkToggleButton* _tmp17_;
	GtkToggleButton* _tmp18_;
	GtkToggleButton* _tmp19_;
	GtkImage* _tmp20_;
	GtkImage* _tmp21_;
	GtkToggleButton* _tmp22_;
	GtkToggleButton* _tmp23_;
	GtkToggleButton* _tmp24_;
	GtkToggleButton* _tmp25_;
	GtkImage* _tmp26_;
	GtkImage* _tmp27_;
	GtkToggleButton* _tmp28_;
	GtkToggleButton* _tmp29_;
	GtkToggleButton* _tmp30_;
	GtkToggleButton* _tmp31_;
	GtkImage* _tmp32_;
	GtkImage* _tmp33_;
	GtkToggleButton* _tmp34_;
	GtkToggleButton* _tmp35_;
	GtkButton* zoom_fit = NULL;
	GtkButton* _tmp36_;
	GtkButton* _tmp37_;
	GtkButton* _tmp38_;
	GtkButton* _tmp39_;
	GtkStyleContext* _tmp40_;
	GtkAction* _tmp41_;
	GtkAction* _tmp42_;
	GtkButton* _tmp43_;
	GtkButton* _tmp44_;
	GtkButton* zoom_original = NULL;
	GtkButton* _tmp45_;
	GtkButton* _tmp46_;
	GtkButton* _tmp47_;
	GtkButton* _tmp48_;
	GtkStyleContext* _tmp49_;
	GtkButton* _tmp50_;
	SliderAssembly* _tmp51_;
	SliderAssembly* _tmp52_;
	GtkGrid* zoom_group = NULL;
	GtkGrid* _tmp53_;
	GtkGrid* _tmp54_;
	GtkGrid* _tmp55_;
	GtkButton* _tmp56_;
	GtkGrid* _tmp57_;
	GtkButton* _tmp58_;
	GtkGrid* _tmp59_;
	SliderAssembly* _tmp60_;
	GtkToolItem* group_wrapper = NULL;
	GtkToolItem* _tmp61_;
	GtkToolItem* _tmp62_;
	GtkGrid* _tmp63_;
	GtkButton* _tmp64_;
	GtkButton* _tmp65_;
	GtkButton* _tmp66_;
	GtkButton* _tmp67_;
	GtkButton* _tmp68_;
	GtkButton* _tmp69_;
	GtkButton* _tmp70_;
	GtkButton* _tmp71_;
	GtkSeparator* _tmp72_;
	GtkSeparator* _tmp73_;
	GtkButton* _tmp74_;
	GtkButton* _tmp75_;
	GtkSeparator* _tmp76_;
	GtkSeparator* _tmp77_;
	GtkToggleButton* _tmp78_;
	GtkToggleButton* _tmp79_;
	GtkSeparator* _tmp80_;
	GtkSeparator* _tmp81_;
	GtkToggleButton* _tmp82_;
	GtkToggleButton* _tmp83_;
	GtkToggleButton* _tmp84_;
	AppWindow* _tmp85_;
	LibraryWindow* _tmp86_;
	LibraryWindow* _tmp87_;
	GtkToolItem* _tmp94_;
	self = (EditingHostPage*) base;
	g_return_if_fail (toolbar != NULL);
	_data11_ = g_slice_new0 (Block11Data);
	_data11_->_ref_count_ = 1;
	_data11_->self = g_object_ref (self);
	_tmp0_ = (GtkButton*) gtk_button_new_from_icon_name ("object-rotate-right", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->rotate_button);
	self->rotate_button = _tmp0_;
	_tmp1_ = self->rotate_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp1_, RESOURCES_ROTATE_CW_TOOLTIP);
	_tmp2_ = self->rotate_button;
	g_signal_connect_object (_tmp2_, "clicked", (GCallback) _editing_host_page_on_rotate_clockwise_gtk_button_clicked, self, 0);
	_tmp3_ = (GtkButton*) gtk_button_new_from_icon_name ("object-flip-horizontal", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->flip_button);
	self->priv->flip_button = _tmp3_;
	_tmp4_ = self->priv->flip_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp4_, RESOURCES_HFLIP_TOOLTIP);
	_tmp5_ = self->priv->flip_button;
	g_signal_connect_object (_tmp5_, "clicked", (GCallback) _editing_host_page_on_flip_horizontally_gtk_button_clicked, self, 0);
	_tmp6_ = (GtkToggleButton*) gtk_toggle_button_new ();
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->priv->crop_button);
	self->priv->crop_button = _tmp6_;
	_tmp7_ = self->priv->crop_button;
	_tmp8_ = (GtkImage*) gtk_image_new_from_icon_name ("image-crop", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp8_);
	_tmp9_ = _tmp8_;
	gtk_button_set_image ((GtkButton*) _tmp7_, (GtkWidget*) _tmp9_);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = self->priv->crop_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp10_, RESOURCES_CROP_TOOLTIP);
	_tmp11_ = self->priv->crop_button;
	g_signal_connect_object (_tmp11_, "toggled", (GCallback) _editing_host_page_on_crop_toggled_gtk_toggle_button_toggled, self, 0);
	_tmp12_ = (GtkToggleButton*) gtk_toggle_button_new ();
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->straighten_button);
	self->priv->straighten_button = _tmp12_;
	_tmp13_ = self->priv->straighten_button;
	_tmp14_ = (GtkImage*) gtk_image_new_from_icon_name ("object-straighten", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp14_);
	_tmp15_ = _tmp14_;
	gtk_button_set_image ((GtkButton*) _tmp13_, (GtkWidget*) _tmp15_);
	_g_object_unref0 (_tmp15_);
	_tmp16_ = self->priv->straighten_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp16_, RESOURCES_STRAIGHTEN_TOOLTIP);
	_tmp17_ = self->priv->straighten_button;
	g_signal_connect_object (_tmp17_, "toggled", (GCallback) _editing_host_page_on_straighten_toggled_gtk_toggle_button_toggled, self, 0);
	_tmp18_ = (GtkToggleButton*) gtk_toggle_button_new ();
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->redeye_button);
	self->priv->redeye_button = _tmp18_;
	_tmp19_ = self->priv->redeye_button;
	_tmp20_ = (GtkImage*) gtk_image_new_from_icon_name ("image-red-eye", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp20_);
	_tmp21_ = _tmp20_;
	gtk_button_set_image ((GtkButton*) _tmp19_, (GtkWidget*) _tmp21_);
	_g_object_unref0 (_tmp21_);
	_tmp22_ = self->priv->redeye_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp22_, RESOURCES_RED_EYE_TOOLTIP);
	_tmp23_ = self->priv->redeye_button;
	g_signal_connect_object (_tmp23_, "toggled", (GCallback) _editing_host_page_on_redeye_toggled_gtk_toggle_button_toggled, self, 0);
	_tmp24_ = (GtkToggleButton*) gtk_toggle_button_new ();
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->adjust_button);
	self->priv->adjust_button = _tmp24_;
	_tmp25_ = self->priv->adjust_button;
	_tmp26_ = (GtkImage*) gtk_image_new_from_icon_name ("image-adjust", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp26_);
	_tmp27_ = _tmp26_;
	gtk_button_set_image ((GtkButton*) _tmp25_, (GtkWidget*) _tmp27_);
	_g_object_unref0 (_tmp27_);
	_tmp28_ = self->priv->adjust_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp28_, RESOURCES_ADJUST_TOOLTIP);
	_tmp29_ = self->priv->adjust_button;
	g_signal_connect_object (_tmp29_, "toggled", (GCallback) _editing_host_page_on_adjust_toggled_gtk_toggle_button_toggled, self, 0);
	_tmp30_ = (GtkToggleButton*) gtk_toggle_button_new ();
	g_object_ref_sink (_tmp30_);
	_g_object_unref0 (self->enhance_button);
	self->enhance_button = _tmp30_;
	_tmp31_ = self->enhance_button;
	_tmp32_ = (GtkImage*) gtk_image_new_from_icon_name ("image-auto-adjust", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp32_);
	_tmp33_ = _tmp32_;
	gtk_button_set_image ((GtkButton*) _tmp31_, (GtkWidget*) _tmp33_);
	_g_object_unref0 (_tmp33_);
	_tmp34_ = self->enhance_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp34_, RESOURCES_ENHANCE_TOOLTIP);
	_tmp35_ = self->enhance_button;
	g_signal_connect_object ((GtkButton*) _tmp35_, "clicked", (GCallback) _editing_host_page_on_enhance_gtk_button_clicked, self, 0);
	_tmp36_ = (GtkButton*) gtk_button_new_from_icon_name ("zoom-fit-best-symbolic", (GtkIconSize) GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp36_);
	zoom_fit = _tmp36_;
	_tmp37_ = zoom_fit;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp37_, _ ("Zoom to fit page"));
	_tmp38_ = zoom_fit;
	gtk_widget_set_valign ((GtkWidget*) _tmp38_, GTK_ALIGN_CENTER);
	_tmp39_ = zoom_fit;
	_tmp40_ = gtk_widget_get_style_context ((GtkWidget*) _tmp39_);
	gtk_style_context_add_class (_tmp40_, GTK_STYLE_CLASS_FLAT);
	_tmp41_ = page_get_action ((Page*) self, "ZoomFit");
	_data11_->zoom_fit_action = _tmp41_;
	_tmp42_ = _data11_->zoom_fit_action;
	_tmp43_ = zoom_fit;
	g_object_bind_property_with_closures ((GObject*) _tmp42_, "sensitive", (GObject*) _tmp43_, "sensitive", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp44_ = zoom_fit;
	g_signal_connect_data (_tmp44_, "clicked", (GCallback) ___lambda50__gtk_button_clicked, block11_data_ref (_data11_), (GClosureNotify) block11_data_unref, 0);
	_tmp45_ = (GtkButton*) gtk_button_new_from_icon_name ("zoom-original-symbolic", (GtkIconSize) GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp45_);
	zoom_original = _tmp45_;
	_tmp46_ = zoom_original;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp46_, _ ("Zoom 1:1"));
	_tmp47_ = zoom_original;
	gtk_widget_set_valign ((GtkWidget*) _tmp47_, GTK_ALIGN_CENTER);
	_tmp48_ = zoom_original;
	_tmp49_ = gtk_widget_get_style_context ((GtkWidget*) _tmp48_);
	gtk_style_context_add_class (_tmp49_, GTK_STYLE_CLASS_FLAT);
	_tmp50_ = zoom_original;
	g_signal_connect_object (_tmp50_, "clicked", (GCallback) ___lambda51__gtk_button_clicked, self, 0);
	_tmp51_ = slider_assembly_new ((gdouble) 0, 1.1, 0.02, (gdouble) 0);
	g_object_ref_sink (_tmp51_);
	_g_object_unref0 (self->priv->zoom_assembly);
	self->priv->zoom_assembly = _tmp51_;
	_tmp52_ = self->priv->zoom_assembly;
	g_signal_connect_object (_tmp52_, "value-changed", (GCallback) _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed, self, 0);
	_tmp53_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp53_);
	zoom_group = _tmp53_;
	_tmp54_ = zoom_group;
	gtk_grid_set_column_spacing (_tmp54_, 6);
	_tmp55_ = zoom_group;
	_tmp56_ = zoom_fit;
	gtk_container_add ((GtkContainer*) _tmp55_, (GtkWidget*) _tmp56_);
	_tmp57_ = zoom_group;
	_tmp58_ = zoom_original;
	gtk_container_add ((GtkContainer*) _tmp57_, (GtkWidget*) _tmp58_);
	_tmp59_ = zoom_group;
	_tmp60_ = self->priv->zoom_assembly;
	gtk_container_add ((GtkContainer*) _tmp59_, (GtkWidget*) _tmp60_);
	_tmp61_ = gtk_tool_item_new ();
	g_object_ref_sink (_tmp61_);
	group_wrapper = _tmp61_;
	_tmp62_ = group_wrapper;
	_tmp63_ = zoom_group;
	gtk_container_add ((GtkContainer*) _tmp62_, (GtkWidget*) _tmp63_);
	_tmp64_ = (GtkButton*) gtk_button_new_from_icon_name ("go-previous-symbolic", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp64_);
	_g_object_unref0 (self->priv->prev_button);
	self->priv->prev_button = _tmp64_;
	_tmp65_ = self->priv->prev_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp65_, _ ("Previous photo"));
	_tmp66_ = self->priv->prev_button;
	g_signal_connect_object (_tmp66_, "clicked", (GCallback) _single_photo_page_on_previous_photo_gtk_button_clicked, (SinglePhotoPage*) self, 0);
	_tmp67_ = (GtkButton*) gtk_button_new_from_icon_name ("go-next-symbolic", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp67_);
	_g_object_unref0 (self->priv->next_button);
	self->priv->next_button = _tmp67_;
	_tmp68_ = self->priv->next_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp68_, _ ("Next photo"));
	_tmp69_ = self->priv->next_button;
	g_signal_connect_object (_tmp69_, "clicked", (GCallback) _single_photo_page_on_next_photo_gtk_button_clicked, (SinglePhotoPage*) self, 0);
	_tmp70_ = self->priv->prev_button;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp70_);
	_tmp71_ = self->priv->next_button;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp71_);
	_tmp72_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_VERTICAL);
	g_object_ref_sink (_tmp72_);
	_tmp73_ = _tmp72_;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp73_);
	_g_object_unref0 (_tmp73_);
	_tmp74_ = self->rotate_button;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp74_);
	_tmp75_ = self->priv->flip_button;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp75_);
	_tmp76_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_VERTICAL);
	g_object_ref_sink (_tmp76_);
	_tmp77_ = _tmp76_;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp77_);
	_g_object_unref0 (_tmp77_);
	_tmp78_ = self->priv->crop_button;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp78_);
	_tmp79_ = self->priv->straighten_button;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp79_);
	_tmp80_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_VERTICAL);
	g_object_ref_sink (_tmp80_);
	_tmp81_ = _tmp80_;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp81_);
	_g_object_unref0 (_tmp81_);
	_tmp82_ = self->priv->redeye_button;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp82_);
	_tmp83_ = self->priv->adjust_button;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp83_);
	_tmp84_ = self->enhance_button;
	gtk_action_bar_pack_start (toolbar, (GtkWidget*) _tmp84_);
	_tmp85_ = app_window_get_instance ();
	_tmp86_ = IS_LIBRARY_WINDOW (_tmp85_) ? ((LibraryWindow*) _tmp85_) : NULL;
	if (_tmp86_ == NULL) {
		_g_object_unref0 (_tmp85_);
	}
	_data11_->app = _tmp86_;
	_tmp87_ = _data11_->app;
	if (_tmp87_ != NULL) {
		GtkButton* _tmp88_;
		GtkButton* _tmp89_;
		GtkSeparator* _tmp90_;
		GtkSeparator* _tmp91_;
		GtkButton* _tmp92_;
		LibraryWindow* _tmp93_;
		_tmp88_ = media_page_create_sidebar_button ();
		_g_object_unref0 (((Page*) self)->show_sidebar_button);
		((Page*) self)->show_sidebar_button = _tmp88_;
		_tmp89_ = ((Page*) self)->show_sidebar_button;
		g_signal_connect_data (_tmp89_, "clicked", (GCallback) ____lambda52__gtk_button_clicked, block11_data_ref (_data11_), (GClosureNotify) block11_data_unref, 0);
		_tmp90_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_VERTICAL);
		g_object_ref_sink (_tmp90_);
		_tmp91_ = _tmp90_;
		gtk_action_bar_pack_end (toolbar, (GtkWidget*) _tmp91_);
		_g_object_unref0 (_tmp91_);
		_tmp92_ = ((Page*) self)->show_sidebar_button;
		gtk_action_bar_pack_end (toolbar, (GtkWidget*) _tmp92_);
		_tmp93_ = _data11_->app;
		page_update_sidebar_action ((Page*) self, !library_window_is_metadata_sidebar_visible (_tmp93_));
	}
	_tmp94_ = group_wrapper;
	gtk_action_bar_pack_end (toolbar, (GtkWidget*) _tmp94_);
	PAGE_CLASS (editing_host_page_parent_class)->add_toolbar_widgets ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), toolbar);
	_g_object_unref0 (group_wrapper);
	_g_object_unref0 (zoom_group);
	_g_object_unref0 (zoom_original);
	_g_object_unref0 (zoom_fit);
	block11_data_unref (_data11_);
	_data11_ = NULL;
}

static void
editing_host_page_on_zoom_assembly_value_changed (EditingHostPage* self)
{
	ZoomState new_zoom_state = {0};
	ZoomState _tmp0_ = {0};
	SliderAssembly* _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	g_return_if_fail (self != NULL);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp0_);
	_tmp1_ = self->priv->zoom_assembly;
	_tmp2_ = slider_assembly_get_slider_value (_tmp1_);
	_tmp3_ = _tmp2_;
	zoom_state_init_rescale (&new_zoom_state, &_tmp0_, _tmp3_);
	if (zoom_state_is_default (&new_zoom_state)) {
		single_photo_page_cancel_zoom ((SinglePhotoPage*) self);
	} else {
		ZoomState _tmp4_;
		_tmp4_ = new_zoom_state;
		single_photo_page_set_zoom_state ((SinglePhotoPage*) self, &_tmp4_);
	}
	single_photo_page_repaint ((SinglePhotoPage*) self, NULL);
	editing_host_page_update_cursor_for_zoom_context (self);
}

static void
editing_host_page_get_cursor_wrt_viewport (EditingHostPage* self,
                                           GdkEventScroll* event,
                                           GdkPoint* result)
{
	GdkPoint cursor_wrt_canvas = {0};
	GdkPoint _tmp0_ = {0};
	GdkRectangle viewport_wrt_canvas = {0};
	ZoomState _tmp1_ = {0};
	GdkRectangle _tmp2_ = {0};
	GdkPoint _result_ = {0};
	GdkPoint _tmp3_ = {0};
	GdkPoint _tmp4_;
	GdkRectangle _tmp5_;
	GdkPoint _tmp6_;
	GdkRectangle _tmp7_;
	GdkPoint _tmp8_;
	GdkRectangle _tmp9_;
	GdkPoint _tmp10_;
	GdkRectangle _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (event != NULL);
	_tmp0_.x = 0;
	cursor_wrt_canvas = _tmp0_;
	cursor_wrt_canvas.x = (gint) event->x;
	cursor_wrt_canvas.y = (gint) event->y;
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp1_);
	zoom_state_get_viewing_rectangle_wrt_screen (&_tmp1_, &_tmp2_);
	viewport_wrt_canvas = _tmp2_;
	_tmp3_.x = 0;
	_result_ = _tmp3_;
	_tmp4_ = cursor_wrt_canvas;
	_tmp5_ = viewport_wrt_canvas;
	_result_.x = _tmp4_.x - _tmp5_.x;
	_tmp6_ = _result_;
	_tmp7_ = viewport_wrt_canvas;
	_result_.x = CLAMP (_tmp6_.x, 0, _tmp7_.width);
	_tmp8_ = cursor_wrt_canvas;
	_tmp9_ = viewport_wrt_canvas;
	_result_.y = _tmp8_.y - _tmp9_.y;
	_tmp10_ = _result_;
	_tmp11_ = viewport_wrt_canvas;
	_result_.y = CLAMP (_tmp10_.y, 0, _tmp11_.height);
	*result = _result_;
	return;
}

static void
editing_host_page_get_cursor_wrt_viewport_center (EditingHostPage* self,
                                                  GdkEventScroll* event,
                                                  GdkPoint* result)
{
	GdkPoint cursor_wrt_viewport = {0};
	GdkPoint _tmp0_ = {0};
	GdkRectangle viewport_wrt_canvas = {0};
	ZoomState _tmp1_ = {0};
	GdkRectangle _tmp2_ = {0};
	GdkPoint viewport_center = {0};
	GdkPoint _tmp3_ = {0};
	GdkRectangle _tmp4_;
	GdkRectangle _tmp5_;
	GdkPoint _tmp6_;
	GdkPoint _tmp7_;
	GdkPoint _tmp8_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (event != NULL);
	editing_host_page_get_cursor_wrt_viewport (self, event, &_tmp0_);
	cursor_wrt_viewport = _tmp0_;
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp1_);
	zoom_state_get_viewing_rectangle_wrt_screen (&_tmp1_, &_tmp2_);
	viewport_wrt_canvas = _tmp2_;
	_tmp3_.x = 0;
	viewport_center = _tmp3_;
	_tmp4_ = viewport_wrt_canvas;
	viewport_center.x = _tmp4_.width / 2;
	_tmp5_ = viewport_wrt_canvas;
	viewport_center.y = _tmp5_.height / 2;
	_tmp6_ = cursor_wrt_viewport;
	_tmp7_ = viewport_center;
	subtract_points (&_tmp6_, &_tmp7_, &_tmp8_);
	*result = _tmp8_;
	return;
}

static void
editing_host_page_get_iso_pixel_under_cursor (EditingHostPage* self,
                                              GdkEventScroll* event,
                                              GdkPoint* result)
{
	GdkPoint viewport_center_iso = {0};
	ZoomState _tmp0_ = {0};
	GdkPoint _tmp1_ = {0};
	ZoomState _tmp2_ = {0};
	GdkPoint _tmp3_ = {0};
	GdkPoint cursor_wrt_center_iso = {0};
	GdkPoint _tmp4_ = {0};
	ZoomState _tmp5_ = {0};
	GdkPoint _tmp6_ = {0};
	GdkPoint _tmp7_;
	GdkPoint _tmp8_;
	GdkPoint _tmp9_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (event != NULL);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp0_);
	zoom_state_get_viewport_center (&_tmp0_, &_tmp1_);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp2_);
	scale_point (&_tmp1_, 1.0 / zoom_state_get_zoom_factor (&_tmp2_), &_tmp3_);
	viewport_center_iso = _tmp3_;
	editing_host_page_get_cursor_wrt_viewport_center (self, event, &_tmp4_);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp5_);
	scale_point (&_tmp4_, 1.0 / zoom_state_get_zoom_factor (&_tmp5_), &_tmp6_);
	cursor_wrt_center_iso = _tmp6_;
	_tmp7_ = viewport_center_iso;
	_tmp8_ = cursor_wrt_center_iso;
	add_points (&_tmp7_, &_tmp8_, &_tmp9_);
	*result = _tmp9_;
	return;
}

static gdouble
editing_host_page_snap_interpolation_factor (EditingHostPage* self,
                                             gdouble interp)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	if (interp < 0.02) {
		interp = 0.02;
	} else {
		if (interp > 1.0) {
			interp = 1.0;
		}
	}
	result = interp;
	return result;
}

static gdouble
editing_host_page_adjust_interpolation_factor (EditingHostPage* self,
                                               gdouble adjustment)
{
	ZoomState _tmp0_ = {0};
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp0_);
	result = editing_host_page_snap_interpolation_factor (self, zoom_state_get_interpolation_factor (&_tmp0_) + adjustment);
	return result;
}

static Block12Data*
block12_data_ref (Block12Data* _data12_)
{
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}

static void
block12_data_unref (void * _userdata_)
{
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		EditingHostPage* self;
		self = _data12_->self;
		_g_object_unref0 (self);
		g_slice_free (Block12Data, _data12_);
	}
}

static gboolean
__lambda53_ (Block12Data* _data12_)
{
	EditingHostPage* self;
	SliderAssembly* _tmp0_;
	guint _tmp1_;
	SliderAssembly* _tmp2_;
	SliderAssembly* _tmp3_;
	gboolean result;
	self = _data12_->self;
	editing_host_page_update_cursor_for_zoom_context (self);
	_tmp0_ = self->priv->zoom_assembly;
	g_signal_parse_name ("value-changed", TYPE_SLIDER_ASSEMBLY, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed, self);
	_tmp2_ = self->priv->zoom_assembly;
	slider_assembly_set_slider_value (_tmp2_, _data12_->interp);
	_tmp3_ = self->priv->zoom_assembly;
	g_signal_connect_object (_tmp3_, "value-changed", (GCallback) _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed, self, 0);
	self->priv->zooming = FALSE;
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda53__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda53_ (self);
	return result;
}

static void
editing_host_page_zoom_about_event_cursor_point (EditingHostPage* self,
                                                 GdkEventScroll* event,
                                                 gdouble zoom_increment)
{
	Block12Data* _data12_;
	gboolean _tmp0_ = FALSE;
	GdkPoint cursor_wrt_viewport_center = {0};
	GdkPoint _tmp1_ = {0};
	GdkPoint iso_pixel_under_cursor = {0};
	GdkPoint _tmp2_ = {0};
	gdouble _tmp3_ = 0.0;
	ZoomState new_zoom_state = {0};
	ZoomState _tmp4_ = {0};
	GdkPoint new_zoomed_old_cursor = {0};
	GdkPoint _tmp5_;
	GdkPoint _tmp6_ = {0};
	GdkPoint desired_new_viewport_center = {0};
	GdkPoint _tmp7_;
	GdkPoint _tmp8_;
	GdkPoint _tmp9_ = {0};
	ZoomState _tmp10_;
	GdkPoint _tmp11_;
	ZoomState _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (event != NULL);
	_data12_ = g_slice_new0 (Block12Data);
	_data12_->_ref_count_ = 1;
	_data12_->self = g_object_ref (self);
	if (self->priv->photo_missing) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->priv->zooming;
	}
	if (_tmp0_) {
		block12_data_unref (_data12_);
		_data12_ = NULL;
		return;
	}
	self->priv->zooming = TRUE;
	editing_host_page_get_cursor_wrt_viewport_center (self, event, &_tmp1_);
	cursor_wrt_viewport_center = _tmp1_;
	editing_host_page_get_iso_pixel_under_cursor (self, event, &_tmp2_);
	iso_pixel_under_cursor = _tmp2_;
	if (page_get_ctrl_pressed ((Page*) self)) {
		_tmp3_ = zoom_increment / 5.0;
	} else {
		_tmp3_ = zoom_increment;
	}
	_data12_->interp = editing_host_page_adjust_interpolation_factor (self, _tmp3_);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp4_);
	zoom_state_init_rescale (&new_zoom_state, &_tmp4_, _data12_->interp);
	if (zoom_state_is_min (&new_zoom_state)) {
		single_photo_page_cancel_zoom ((SinglePhotoPage*) self);
		editing_host_page_update_cursor_for_zoom_context (self);
		single_photo_page_repaint ((SinglePhotoPage*) self, NULL);
		block12_data_unref (_data12_);
		_data12_ = NULL;
		return;
	}
	_tmp5_ = iso_pixel_under_cursor;
	scale_point (&_tmp5_, zoom_state_get_zoom_factor (&new_zoom_state), &_tmp6_);
	new_zoomed_old_cursor = _tmp6_;
	_tmp7_ = new_zoomed_old_cursor;
	_tmp8_ = cursor_wrt_viewport_center;
	subtract_points (&_tmp7_, &_tmp8_, &_tmp9_);
	desired_new_viewport_center = _tmp9_;
	_tmp10_ = new_zoom_state;
	_tmp11_ = desired_new_viewport_center;
	zoom_state_init_pan (&new_zoom_state, &_tmp10_, &_tmp11_);
	_tmp12_ = new_zoom_state;
	single_photo_page_set_zoom_state ((SinglePhotoPage*) self, &_tmp12_);
	single_photo_page_repaint ((SinglePhotoPage*) self, NULL);
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda53__gsource_func, block12_data_ref (_data12_), block12_data_unref);
	block12_data_unref (_data12_);
	_data12_ = NULL;
}

void
editing_host_page_snap_zoom_to_min (EditingHostPage* self)
{
	SliderAssembly* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->zoom_assembly;
	slider_assembly_set_slider_value (_tmp0_, 0.0);
}

void
editing_host_page_snap_zoom_to_max (EditingHostPage* self)
{
	SliderAssembly* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->zoom_assembly;
	slider_assembly_set_slider_value (_tmp0_, 1.0);
}

void
editing_host_page_snap_zoom_to_isomorphic (EditingHostPage* self)
{
	ZoomState iso_state = {0};
	ZoomState _tmp0_ = {0};
	SliderAssembly* _tmp1_;
	g_return_if_fail (self != NULL);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp0_);
	zoom_state_init_rescale_to_isomorphic (&iso_state, &_tmp0_);
	_tmp1_ = self->priv->zoom_assembly;
	slider_assembly_set_slider_value (_tmp1_, zoom_state_get_interpolation_factor (&iso_state));
}

static gboolean
editing_host_page_real_on_zoom_assembly_key_press (EditingHostPage* self,
                                                   GdkEventKey* event)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	static GQuark _tmp2_label6 = 0;
	static GQuark _tmp2_label7 = 0;
	gboolean result;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = gdk_keyval_name (event->keyval);
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	if (((_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("equal")))) || (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("plus"))))) || (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("KP_Add"))))) {
		switch (0) {
			default:
			{
				page_activate_action ((Page*) self, "IncreaseSize");
				result = TRUE;
				return result;
			}
		}
	} else if (((_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("minus")))) || (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("underscore"))))) || (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("KP_Subtract"))))) {
		switch (0) {
			default:
			{
				page_activate_action ((Page*) self, "DecreaseSize");
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label6) ? _tmp2_label6 : (_tmp2_label6 = g_quark_from_static_string ("KP_Divide")))) {
		switch (0) {
			default:
			{
				page_activate_action ((Page*) self, "Zoom100");
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label7) ? _tmp2_label7 : (_tmp2_label7 = g_quark_from_static_string ("KP_Multiply")))) {
		switch (0) {
			default:
			{
				page_activate_action ((Page*) self, "ZoomFit");
				result = TRUE;
				return result;
			}
		}
	}
	result = FALSE;
	return result;
}

gboolean
editing_host_page_on_zoom_assembly_key_press (EditingHostPage* self,
                                              GdkEventKey* event)
{
	EditingHostPageClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->on_zoom_assembly_key_press) {
		return _klass_->on_zoom_assembly_key_press (self, event);
	}
	return FALSE;
}

static void
editing_host_page_real_on_increase_size (EditingHostPage* self)
{
	SliderAssembly* _tmp0_;
	_tmp0_ = self->priv->zoom_assembly;
	slider_assembly_increase_step (_tmp0_);
}

void
editing_host_page_on_increase_size (EditingHostPage* self)
{
	EditingHostPageClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->on_increase_size) {
		_klass_->on_increase_size (self);
	}
}

static void
editing_host_page_real_on_decrease_size (EditingHostPage* self)
{
	SliderAssembly* _tmp0_;
	_tmp0_ = self->priv->zoom_assembly;
	slider_assembly_decrease_step (_tmp0_);
}

void
editing_host_page_on_decrease_size (EditingHostPage* self)
{
	EditingHostPageClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->on_decrease_size) {
		_klass_->on_decrease_size (self);
	}
}

static void
editing_host_page_real_save_zoom_state (SinglePhotoPage* base)
{
	EditingHostPage * self;
	SliderAssembly* _tmp0_;
	gdouble _tmp1_;
	gdouble _tmp2_;
	self = (EditingHostPage*) base;
	SINGLE_PHOTO_PAGE_CLASS (editing_host_page_parent_class)->save_zoom_state (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage));
	_tmp0_ = self->priv->zoom_assembly;
	_tmp1_ = slider_assembly_get_slider_value (_tmp0_);
	_tmp2_ = _tmp1_;
	self->priv->saved_slider_val = _tmp2_;
}

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

static ZoomBuffer*
editing_host_page_real_get_zoom_buffer (SinglePhotoPage* base)
{
	EditingHostPage * self;
	ZoomBuffer* _tmp0_;
	ZoomBuffer* _tmp1_;
	ZoomBuffer* result;
	self = (EditingHostPage*) base;
	_tmp0_ = self->priv->zoom_buffer;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static gboolean
editing_host_page_real_on_mousewheel_up (Page* base,
                                         GdkEventScroll* event)
{
	EditingHostPage * self;
	gboolean result;
	self = (EditingHostPage*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	if (page_get_ctrl_pressed ((Page*) self)) {
		SliderAssembly* _tmp0_;
		_tmp0_ = self->priv->zoom_assembly;
		if (gtk_widget_get_sensitive ((GtkWidget*) _tmp0_)) {
			gdouble _tmp1_ = 0.0;
			if (page_get_alt_pressed ((Page*) self)) {
				_tmp1_ = EDITING_HOST_PAGE_ZOOM_INCREMENT_SIZE;
			} else {
				_tmp1_ = EDITING_HOST_PAGE_ZOOM_INCREMENT_SIZE * 5.0;
			}
			editing_host_page_zoom_about_event_cursor_point (self, event, _tmp1_);
		}
	} else {
	}
	result = FALSE;
	return result;
}

static gboolean
editing_host_page_real_on_mousewheel_down (Page* base,
                                           GdkEventScroll* event)
{
	EditingHostPage * self;
	gboolean result;
	self = (EditingHostPage*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	if (page_get_ctrl_pressed ((Page*) self)) {
		SliderAssembly* _tmp0_;
		_tmp0_ = self->priv->zoom_assembly;
		if (gtk_widget_get_sensitive ((GtkWidget*) _tmp0_)) {
			gdouble _tmp1_ = 0.0;
			if (page_get_alt_pressed ((Page*) self)) {
				_tmp1_ = -EDITING_HOST_PAGE_ZOOM_INCREMENT_SIZE;
			} else {
				_tmp1_ = (-EDITING_HOST_PAGE_ZOOM_INCREMENT_SIZE) * 5.0;
			}
			editing_host_page_zoom_about_event_cursor_point (self, event, _tmp1_);
		}
	} else {
	}
	result = FALSE;
	return result;
}

static void
editing_host_page_real_restore_zoom_state (SinglePhotoPage* base)
{
	EditingHostPage * self;
	SliderAssembly* _tmp0_;
	guint _tmp1_;
	SliderAssembly* _tmp2_;
	SliderAssembly* _tmp3_;
	self = (EditingHostPage*) base;
	SINGLE_PHOTO_PAGE_CLASS (editing_host_page_parent_class)->restore_zoom_state (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage));
	_tmp0_ = self->priv->zoom_assembly;
	g_signal_parse_name ("value-changed", TYPE_SLIDER_ASSEMBLY, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed, self);
	_tmp2_ = self->priv->zoom_assembly;
	slider_assembly_set_slider_value (_tmp2_, self->priv->saved_slider_val);
	_tmp3_ = self->priv->zoom_assembly;
	g_signal_connect_object (_tmp3_, "value-changed", (GCallback) _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed, self, 0);
}

static gboolean
editing_host_page_real_is_zoom_supported (SinglePhotoPage* base)
{
	EditingHostPage * self;
	gboolean result;
	self = (EditingHostPage*) base;
	result = TRUE;
	return result;
}

static void
editing_host_page_real_set_container (Page* base,
                                      GtkWindow* container)
{
	EditingHostPage * self;
	self = (EditingHostPage*) base;
	g_return_if_fail (container != NULL);
	PAGE_CLASS (editing_host_page_parent_class)->set_container ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), container);
	if (!IS_FULLSCREEN_WINDOW (container)) {
		DragAndDropHandler* _tmp0_;
		_tmp0_ = drag_and_drop_handler_new ((Page*) self);
		_drag_and_drop_handler_unref0 (self->priv->dnd_handler);
		self->priv->dnd_handler = _tmp0_;
	}
}

void
editing_host_page_update_enhance_action (EditingHostPage* self)
{
	g_return_if_fail (self != NULL);
	if (editing_host_page_has_photo (self)) {
		GtkAction* action = NULL;
		GtkAction* _tmp0_;
		GtkAction* _tmp1_;
		gboolean is_enhanced = FALSE;
		Photo* _tmp2_;
		Photo* _tmp3_;
		gboolean _tmp4_;
		const gchar* _tmp5_ = NULL;
		GtkAction* _tmp6_;
		GtkAction* _tmp7_;
		GtkToggleButton* _tmp8_;
		guint _tmp9_;
		GtkToggleButton* _tmp10_;
		Photo* _tmp11_;
		Photo* _tmp12_;
		GtkToggleButton* _tmp13_;
		_tmp0_ = page_get_action ((Page*) self, "Enhance");
		action = _tmp0_;
		_tmp1_ = action;
		_vala_assert (_tmp1_ != NULL, "action != null");
		_tmp2_ = editing_host_page_get_photo (self);
		_tmp3_ = _tmp2_;
		_tmp4_ = photo_is_enhanced (_tmp3_);
		_g_object_unref0 (_tmp3_);
		is_enhanced = _tmp4_;
		if (is_enhanced) {
			_tmp5_ = RESOURCES_UNENHANCE_MENU;
		} else {
			_tmp5_ = RESOURCES_ENHANCE_MENU;
		}
		_tmp6_ = action;
		gtk_action_set_label (_tmp6_, _tmp5_);
		_tmp7_ = action;
		gtk_action_set_sensitive (_tmp7_, TRUE);
		_tmp8_ = self->enhance_button;
		g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp9_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkButton*) _tmp8_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp9_, 0, NULL, (GCallback) _editing_host_page_on_enhance_gtk_button_clicked, self);
		_tmp10_ = self->enhance_button;
		_tmp11_ = editing_host_page_get_photo (self);
		_tmp12_ = _tmp11_;
		gtk_toggle_button_set_active (_tmp10_, photo_is_enhanced (_tmp12_));
		_g_object_unref0 (_tmp12_);
		_tmp13_ = self->enhance_button;
		g_signal_connect_object ((GtkButton*) _tmp13_, "clicked", (GCallback) _editing_host_page_on_enhance_gtk_button_clicked, self, 0);
		_g_object_unref0 (action);
	} else {
		page_set_action_sensitive ((Page*) self, "Enhance", FALSE);
	}
}

gboolean
editing_host_page_has_photo (EditingHostPage* self)
{
	Photo* _tmp0_;
	Photo* _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = editing_host_page_get_photo (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_ != NULL;
	_g_object_unref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

Photo*
editing_host_page_get_photo (EditingHostPage* self)
{
	ViewCollection* _tmp0_;
	ViewCollection* _tmp1_;
	gboolean _tmp2_;
	ViewCollection* _tmp3_;
	ViewCollection* _tmp4_;
	ViewCollection* _tmp5_;
	ViewCollection* _tmp6_;
	DataView* _tmp7_;
	DataView* _tmp8_;
	DataSource* _tmp9_;
	DataSource* _tmp10_;
	Photo* _tmp11_;
	Photo* _tmp12_;
	Photo* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = page_get_view ((Page*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = view_collection_get_selected_count (_tmp1_) == 0;
	_data_collection_unref0 (_tmp1_);
	if (_tmp2_) {
		result = NULL;
		return result;
	}
	_tmp3_ = page_get_view ((Page*) self);
	_tmp4_ = _tmp3_;
	_vala_assert (view_collection_get_selected_count (_tmp4_) == 1, "get_view ().get_selected_count () == 1");
	_data_collection_unref0 (_tmp4_);
	_tmp5_ = page_get_view ((Page*) self);
	_tmp6_ = _tmp5_;
	_tmp7_ = view_collection_get_selected_at (_tmp6_, 0);
	_tmp8_ = _tmp7_;
	_tmp9_ = data_view_get_source (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, TYPE_PHOTO, Photo));
	_tmp12_ = _tmp11_;
	_g_object_unref0 (_tmp8_);
	_data_collection_unref0 (_tmp6_);
	result = _tmp12_;
	return result;
}

static void
editing_host_page_real_photo_changing (EditingHostPage* self,
                                       Photo* new_photo)
{
	g_return_if_fail (new_photo != NULL);
	if (photo_get_file_format (new_photo) == PHOTO_FILE_FORMAT_RAW) {
		editing_host_page_set_photo_missing (self, FALSE);
	} else {
		GFile* _tmp0_;
		GFile* _tmp1_;
		_tmp0_ = media_source_get_file ((MediaSource*) new_photo);
		_tmp1_ = _tmp0_;
		editing_host_page_set_photo_missing (self, !g_file_query_exists (_tmp1_, NULL));
		_g_object_unref0 (_tmp1_);
	}
	editing_host_page_update_enhance_action (self);
	editing_host_page_update_ui (self, self->priv->photo_missing);
}

void
editing_host_page_photo_changing (EditingHostPage* self,
                                  Photo* new_photo)
{
	EditingHostPageClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->photo_changing) {
		_klass_->photo_changing (self, new_photo);
	}
}

static void
editing_host_page_set_photo (EditingHostPage* self,
                             Photo* photo)
{
	SliderAssembly* _tmp0_;
	guint _tmp1_;
	SliderAssembly* _tmp2_;
	SliderAssembly* _tmp3_;
	DataView* view = NULL;
	ViewCollection* _tmp4_;
	ViewCollection* _tmp5_;
	DataView* _tmp6_;
	DataView* _tmp7_;
	DataView* _tmp8_;
	ViewCollection* _tmp9_;
	ViewCollection* _tmp10_;
	Marker* marker = NULL;
	ViewCollection* _tmp11_;
	ViewCollection* _tmp12_;
	DataView* _tmp13_;
	Marker* _tmp14_;
	Marker* _tmp15_;
	ViewCollection* _tmp16_;
	ViewCollection* _tmp17_;
	Marker* _tmp18_;
	ViewCollection* _tmp19_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (photo != NULL);
	_tmp0_ = self->priv->zoom_assembly;
	g_signal_parse_name ("value-changed", TYPE_SLIDER_ASSEMBLY, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed, self);
	_tmp2_ = self->priv->zoom_assembly;
	slider_assembly_set_slider_value (_tmp2_, 0.0);
	_tmp3_ = self->priv->zoom_assembly;
	g_signal_connect_object (_tmp3_, "value-changed", (GCallback) _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed, self, 0);
	editing_host_page_photo_changing (self, photo);
	_tmp4_ = page_get_view ((Page*) self);
	_tmp5_ = _tmp4_;
	_tmp6_ = view_collection_get_view_for_source (_tmp5_, (DataSource*) photo);
	_tmp7_ = _tmp6_;
	_data_collection_unref0 (_tmp5_);
	view = _tmp7_;
	_tmp8_ = view;
	_vala_assert (_tmp8_ != NULL, "view != null");
	_tmp9_ = page_get_view ((Page*) self);
	_tmp10_ = _tmp9_;
	view_collection_unselect_all (_tmp10_);
	_data_collection_unref0 (_tmp10_);
	_tmp11_ = page_get_view ((Page*) self);
	_tmp12_ = _tmp11_;
	_tmp13_ = view;
	_tmp14_ = data_collection_mark ((DataCollection*) _tmp12_, (DataObject*) _tmp13_);
	_tmp15_ = _tmp14_;
	_data_collection_unref0 (_tmp12_);
	marker = _tmp15_;
	_tmp16_ = page_get_view ((Page*) self);
	_tmp17_ = _tmp16_;
	_tmp18_ = marker;
	view_collection_select_marked (_tmp17_, _tmp18_);
	_data_collection_unref0 (_tmp17_);
	_tmp19_ = self->priv->parent_view;
	if (_tmp19_ != NULL) {
		ViewCollection* _tmp20_;
		DataView* view_in_parent = NULL;
		ViewCollection* _tmp21_;
		DataView* _tmp22_;
		DataView* _tmp23_;
		_tmp20_ = self->priv->parent_view;
		view_collection_unselect_all (_tmp20_);
		_tmp21_ = self->priv->parent_view;
		_tmp22_ = view_collection_get_view_for_source_filtered (_tmp21_, (DataSource*) photo);
		view_in_parent = _tmp22_;
		_tmp23_ = view_in_parent;
		if (NULL != _tmp23_) {
			ViewCollection* _tmp24_;
			ViewCollection* _tmp25_;
			DataView* _tmp26_;
			Marker* _tmp27_;
			Marker* _tmp28_;
			_tmp24_ = self->priv->parent_view;
			_tmp25_ = self->priv->parent_view;
			_tmp26_ = view_in_parent;
			_tmp27_ = data_collection_mark ((DataCollection*) _tmp25_, (DataObject*) _tmp26_);
			_tmp28_ = _tmp27_;
			view_collection_select_marked (_tmp24_, _tmp28_);
			_g_object_unref0 (_tmp28_);
		}
		_g_object_unref0 (view_in_parent);
	}
	_g_object_unref0 (marker);
	_g_object_unref0 (view);
}

static void
editing_host_page_real_realize (GtkWidget* base)
{
	EditingHostPage * self;
	self = (EditingHostPage*) base;
	GTK_WIDGET_CLASS (editing_host_page_parent_class)->realize ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage));
	editing_host_page_rebuild_caches (self, "realize");
}

static void
editing_host_page_real_switched_to (Page* base)
{
	EditingHostPage * self;
	gboolean _tmp0_ = FALSE;
	LibraryWindow* app = NULL;
	AppWindow* _tmp3_;
	LibraryWindow* _tmp4_;
	LibraryWindow* _tmp5_;
	self = (EditingHostPage*) base;
	PAGE_CLASS (editing_host_page_parent_class)->switched_to ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage));
	editing_host_page_rebuild_caches (self, "switched_to");
	if (editing_host_page_has_photo (self)) {
		_tmp0_ = self->priv->pixbuf_dirty;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		Photo* _tmp1_;
		Photo* _tmp2_;
		_tmp1_ = editing_host_page_get_photo (self);
		_tmp2_ = _tmp1_;
		editing_host_page_replace_photo (self, _tmp2_);
		_g_object_unref0 (_tmp2_);
	}
	_tmp3_ = app_window_get_instance ();
	_tmp4_ = IS_LIBRARY_WINDOW (_tmp3_) ? ((LibraryWindow*) _tmp3_) : NULL;
	if (_tmp4_ == NULL) {
		_g_object_unref0 (_tmp3_);
	}
	app = _tmp4_;
	_tmp5_ = app;
	if (_tmp5_ != NULL) {
		LibraryWindow* _tmp6_;
		_tmp6_ = app;
		page_update_sidebar_action ((Page*) self, !library_window_is_metadata_sidebar_visible (_tmp6_));
	}
	_g_object_unref0 (app);
}

static void
editing_host_page_real_switching_from (Page* base)
{
	EditingHostPage * self;
	Dimensions _tmp0_ = {0};
	gboolean _tmp1_ = FALSE;
	ViewCollection* _tmp12_;
	ViewCollection* _tmp13_;
	self = (EditingHostPage*) base;
	PAGE_CLASS (editing_host_page_parent_class)->switching_from ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage));
	self->priv->is_pan_in_progress = FALSE;
	dimensions_init (&_tmp0_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp0_, FALSE);
	if (editing_host_page_has_photo (self)) {
		ViewCollection* _tmp2_;
		_tmp2_ = self->priv->parent_view;
		_tmp1_ = _tmp2_ != NULL;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		ViewCollection* _tmp3_;
		ViewCollection* _tmp4_;
		ViewCollection* _tmp5_;
		Photo* _tmp6_;
		Photo* _tmp7_;
		DataView* _tmp8_;
		DataView* _tmp9_;
		Marker* _tmp10_;
		Marker* _tmp11_;
		_tmp3_ = self->priv->parent_view;
		_tmp4_ = self->priv->parent_view;
		_tmp5_ = self->priv->parent_view;
		_tmp6_ = editing_host_page_get_photo (self);
		_tmp7_ = _tmp6_;
		_tmp8_ = view_collection_get_view_for_source (_tmp5_, (DataSource*) _tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = data_collection_mark ((DataCollection*) _tmp4_, (DataObject*) _tmp9_);
		_tmp11_ = _tmp10_;
		view_collection_select_marked (_tmp3_, _tmp11_);
		_g_object_unref0 (_tmp11_);
		_g_object_unref0 (_tmp9_);
		_g_object_unref0 (_tmp7_);
	}
	_data_collection_unref0 (self->priv->parent_view);
	self->priv->parent_view = NULL;
	_tmp12_ = page_get_view ((Page*) self);
	_tmp13_ = _tmp12_;
	data_collection_clear ((DataCollection*) _tmp13_);
	_data_collection_unref0 (_tmp13_);
}

static void
_editing_host_page_on_selection_changed_view_collection_items_selected (ViewCollection* _sender,
                                                                        GeeIterable* selected,
                                                                        gpointer self)
{
	editing_host_page_on_selection_changed ((EditingHostPage*) self, selected);
}

static void
editing_host_page_real_switching_to_fullscreen (Page* base,
                                                FullscreenWindow* fsw)
{
	EditingHostPage * self;
	Dimensions _tmp0_ = {0};
	Page* page = NULL;
	Page* _tmp1_;
	Page* _tmp2_;
	self = (EditingHostPage*) base;
	g_return_if_fail (fsw != NULL);
	PAGE_CLASS (editing_host_page_parent_class)->switching_to_fullscreen ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), fsw);
	dimensions_init (&_tmp0_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp0_, FALSE);
	single_photo_page_cancel_zoom ((SinglePhotoPage*) self);
	self->priv->is_pan_in_progress = FALSE;
	_tmp1_ = page_window_get_current_page ((PageWindow*) fsw);
	page = _tmp1_;
	_tmp2_ = page;
	if (_tmp2_ != NULL) {
		Page* _tmp3_;
		ViewCollection* _tmp4_;
		ViewCollection* _tmp5_;
		_tmp3_ = page;
		_tmp4_ = page_get_view (_tmp3_);
		_tmp5_ = _tmp4_;
		g_signal_connect_object (_tmp5_, "items-selected", (GCallback) _editing_host_page_on_selection_changed_view_collection_items_selected, self, 0);
		_data_collection_unref0 (_tmp5_);
	}
	_g_object_unref0 (page);
}

static void
editing_host_page_real_returning_from_fullscreen (Page* base,
                                                  FullscreenWindow* fsw)
{
	EditingHostPage * self;
	Page* page = NULL;
	Page* _tmp0_;
	Page* _tmp1_;
	self = (EditingHostPage*) base;
	g_return_if_fail (fsw != NULL);
	PAGE_CLASS (editing_host_page_parent_class)->returning_from_fullscreen ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), fsw);
	single_photo_page_repaint ((SinglePhotoPage*) self, NULL);
	_tmp0_ = page_window_get_current_page ((PageWindow*) fsw);
	page = _tmp0_;
	_tmp1_ = page;
	if (_tmp1_ != NULL) {
		Page* _tmp2_;
		ViewCollection* _tmp3_;
		ViewCollection* _tmp4_;
		guint _tmp5_;
		_tmp2_ = page;
		_tmp3_ = page_get_view (_tmp2_);
		_tmp4_ = _tmp3_;
		g_signal_parse_name ("items-selected", TYPE_VIEW_COLLECTION, &_tmp5_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _editing_host_page_on_selection_changed_view_collection_items_selected, self);
		_data_collection_unref0 (_tmp4_);
	}
	_g_object_unref0 (page);
}

static void
editing_host_page_on_selection_changed (EditingHostPage* self,
                                        GeeIterable* selected)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (selected != NULL);
	{
		GeeIterator* _view_it = NULL;
		GeeIterator* _tmp0_;
		_tmp0_ = gee_iterable_iterator (selected);
		_view_it = _tmp0_;
		while (TRUE) {
			DataView* view = NULL;
			gpointer _tmp1_;
			DataView* _tmp2_;
			DataSource* _tmp3_;
			DataSource* _tmp4_;
			if (!gee_iterator_next (_view_it)) {
				break;
			}
			_tmp1_ = gee_iterator_get (_view_it);
			view = (DataView*) _tmp1_;
			_tmp2_ = view;
			_tmp3_ = data_view_get_source (_tmp2_);
			_tmp4_ = _tmp3_;
			editing_host_page_replace_photo (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, TYPE_PHOTO, Photo));
			_g_object_unref0 (view);
			break;
		}
		_g_object_unref0 (_view_it);
	}
}

void
editing_host_page_enable_rotate (EditingHostPage* self,
                                 gboolean should_enable)
{
	GtkButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->rotate_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, should_enable);
}

static void
_editing_host_page_on_pixbuf_fetched_pixbuf_cache_fetched (PixbufCache* _sender,
                                                           Photo* photo,
                                                           GdkPixbuf* pixbuf,
                                                           GError* err,
                                                           gpointer self)
{
	editing_host_page_on_pixbuf_fetched ((EditingHostPage*) self, photo, pixbuf, err);
}

static gboolean
_editing_host_page_master_cache_filter_pixbuf_cache_cache_filter (Photo* photo,
                                                                  gpointer self)
{
	gboolean result;
	result = editing_host_page_master_cache_filter ((EditingHostPage*) self, photo);
	return result;
}

static void
editing_host_page_rebuild_caches (EditingHostPage* self,
                                  const gchar* caller)
{
	Scaling scaling = {0};
	Scaling _tmp0_ = {0};
	gboolean _tmp1_ = FALSE;
	PixbufCache* _tmp2_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	PixbufCache* _tmp8_;
	SourceCollection* _tmp12_;
	Scaling _tmp13_;
	PixbufCache* _tmp14_;
	PixbufCache* _tmp15_;
	SourceCollection* _tmp16_;
	Scaling _tmp17_;
	PixbufCache* _tmp18_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (caller != NULL);
	single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp0_);
	scaling = _tmp0_;
	_tmp2_ = self->priv->cache;
	if (_tmp2_ != NULL) {
		PixbufCache* _tmp3_;
		Scaling _tmp4_ = {0};
		Scaling _tmp5_;
		_tmp3_ = self->priv->cache;
		pixbuf_cache_get_scaling (_tmp3_, &_tmp4_);
		_tmp5_ = scaling;
		_tmp1_ = scaling_equals (&_tmp4_, &_tmp5_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		return;
	}
	_tmp6_ = scaling_to_string (&scaling);
	_tmp7_ = _tmp6_;
	g_debug ("EditingHostPage.vala:596: Rebuild pixbuf caches: %s (%s)", caller, _tmp7_);
	_g_free0 (_tmp7_);
	_tmp8_ = self->priv->cache;
	if (_tmp8_ != NULL) {
		PixbufCache* _tmp9_;
		guint _tmp10_;
		PixbufCache* _tmp11_;
		_tmp9_ = self->priv->cache;
		g_signal_parse_name ("fetched", TYPE_PIXBUF_CACHE, &_tmp10_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp9_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp10_, 0, NULL, (GCallback) _editing_host_page_on_pixbuf_fetched_pixbuf_cache_fetched, self);
		_tmp11_ = self->priv->cache;
		pixbuf_cache_cancel_all (_tmp11_);
	}
	_tmp12_ = self->priv->_sources;
	_tmp13_ = scaling;
	_tmp14_ = pixbuf_cache_new (_tmp12_, PIXBUF_CACHE_PHOTO_TYPE_BASELINE, &_tmp13_, EDITING_HOST_PAGE_PIXBUF_CACHE_COUNT, NULL, NULL);
	_g_object_unref0 (self->priv->cache);
	self->priv->cache = _tmp14_;
	_tmp15_ = self->priv->cache;
	g_signal_connect_object (_tmp15_, "fetched", (GCallback) _editing_host_page_on_pixbuf_fetched_pixbuf_cache_fetched, self, 0);
	_tmp16_ = self->priv->_sources;
	_tmp17_ = scaling;
	_tmp18_ = pixbuf_cache_new (_tmp16_, PIXBUF_CACHE_PHOTO_TYPE_MASTER, &_tmp17_, EDITING_HOST_PAGE_ORIGINAL_PIXBUF_CACHE_COUNT, _editing_host_page_master_cache_filter_pixbuf_cache_cache_filter, self);
	_g_object_unref0 (self->priv->master_cache);
	self->priv->master_cache = _tmp18_;
	editing_host_page_refresh_caches (self, caller);
}

static void
editing_host_page_refresh_caches (EditingHostPage* self,
                                  const gchar* caller)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (caller != NULL);
	if (editing_host_page_has_photo (self)) {
		Photo* _tmp0_;
		Photo* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		ViewCollection* _tmp4_;
		ViewCollection* _tmp5_;
		Photo* _tmp6_;
		Photo* _tmp7_;
		_tmp0_ = editing_host_page_get_photo (self);
		_tmp1_ = _tmp0_;
		_tmp2_ = data_object_to_string ((DataObject*) _tmp1_);
		_tmp3_ = _tmp2_;
		g_debug ("EditingHostPage.vala:617: Refresh pixbuf caches (%s): prefetching neig" \
"hbors of %s", caller, _tmp3_);
		_g_free0 (_tmp3_);
		_g_object_unref0 (_tmp1_);
		_tmp4_ = page_get_view ((Page*) self);
		_tmp5_ = _tmp4_;
		_tmp6_ = editing_host_page_get_photo (self);
		_tmp7_ = _tmp6_;
		editing_host_page_prefetch_neighbors (self, _tmp5_, _tmp7_);
		_g_object_unref0 (_tmp7_);
		_data_collection_unref0 (_tmp5_);
	} else {
		g_debug ("EditingHostPage.vala:621: Refresh pixbuf caches (%s): (no photo)", caller);
	}
}

static gboolean
editing_host_page_master_cache_filter (EditingHostPage* self,
                                       Photo* photo)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (photo != NULL, FALSE);
	if (photo_has_transformations (photo)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = photo_has_editable (photo);
	}
	result = _tmp0_;
	return result;
}

static void
editing_host_page_on_pixbuf_fetched (EditingHostPage* self,
                                     Photo* photo,
                                     GdkPixbuf* pixbuf,
                                     GError* err)
{
	Photo* _tmp0_;
	Photo* _tmp1_;
	gboolean _tmp2_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (photo != NULL);
	_tmp0_ = editing_host_page_get_photo (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = !data_source_equals ((DataSource*) photo, (DataSource*) _tmp1_);
	_g_object_unref0 (_tmp1_);
	if (_tmp2_) {
		return;
	}
	if (pixbuf != NULL) {
		gboolean _tmp3_ = FALSE;
		ZoomBuffer* _tmp4_;
		Dimensions max_dim = {0};
		Dimensions _tmp9_ = {0};
		EditingToolsEditingTool* _tmp10_;
		Dimensions _tmp22_;
		_tmp4_ = self->priv->zoom_buffer;
		if (_tmp4_ != NULL) {
			ZoomBuffer* _tmp5_;
			Photo* _tmp6_;
			Photo* _tmp7_;
			_tmp5_ = self->priv->zoom_buffer;
			_tmp6_ = zoom_buffer_get_backing_photo (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp3_ = _tmp7_ == photo;
			_g_object_unref0 (_tmp7_);
		} else {
			_tmp3_ = FALSE;
		}
		if (_tmp3_) {
			ZoomBuffer* _tmp8_;
			_tmp8_ = zoom_buffer_new ((SinglePhotoPage*) self, photo, pixbuf);
			_g_object_unref0 (self->priv->zoom_buffer);
			self->priv->zoom_buffer = _tmp8_;
		}
		media_source_get_dimensions ((MediaSource*) photo, PHOTO_EXCEPTION_NONE, &_tmp9_);
		max_dim = _tmp9_;
		_tmp10_ = self->priv->current_tool;
		if (_tmp10_ != NULL) {
			{
				Dimensions tool_pixbuf_dim = {0};
				GdkPixbuf* tool_pixbuf = NULL;
				EditingToolsEditingTool* _tmp11_;
				Scaling _tmp12_ = {0};
				Dimensions _tmp13_ = {0};
				GdkPixbuf* _tmp14_;
				GdkPixbuf* _tmp15_;
				_tmp11_ = self->priv->current_tool;
				single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp12_);
				_tmp14_ = editing_tools_editing_tool_get_display_pixbuf (_tmp11_, &_tmp12_, photo, &_tmp13_, &_inner_error0_);
				tool_pixbuf_dim = _tmp13_;
				tool_pixbuf = _tmp14_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_tmp15_ = tool_pixbuf;
				if (_tmp15_ != NULL) {
					GdkPixbuf* _tmp16_;
					Dimensions _tmp17_;
					_tmp16_ = tool_pixbuf;
					pixbuf = _tmp16_;
					_tmp17_ = tool_pixbuf_dim;
					max_dim = _tmp17_;
				}
				_g_object_unref0 (tool_pixbuf);
			}
			goto __finally0;
			__catch0_g_error:
			{
				GError* err = NULL;
				gchar* _tmp18_;
				gchar* _tmp19_;
				GError* _tmp20_;
				const gchar* _tmp21_;
				err = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp18_ = data_object_to_string ((DataObject*) photo);
				_tmp19_ = _tmp18_;
				_tmp20_ = err;
				_tmp21_ = _tmp20_->message;
				g_warning ("EditingHostPage.vala:653: Unable to fetch tool pixbuf for %s: %s", _tmp19_, _tmp21_);
				_g_free0 (_tmp19_);
				editing_host_page_set_photo_missing (self, TRUE);
				_g_error_free0 (err);
				return;
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
		}
		_tmp22_ = max_dim;
		single_photo_page_set_pixbuf ((SinglePhotoPage*) self, pixbuf, &_tmp22_, NULL);
		self->priv->pixbuf_dirty = FALSE;
		editing_host_page_notify_photo_backing_missing (self, G_TYPE_CHECK_INSTANCE_CAST (photo, TYPE_PHOTO, Photo), FALSE);
	} else {
		if (err != NULL) {
			editing_host_page_set_photo_missing (self, TRUE);
			editing_host_page_notify_photo_backing_missing (self, G_TYPE_CHECK_INSTANCE_CAST (photo, TYPE_PHOTO, Photo), TRUE);
		}
	}
}

static void
editing_host_page_prefetch_neighbors (EditingHostPage* self,
                                      ViewCollection* controller,
                                      Photo* photo)
{
	PixbufCachePixbufCacheBatch* normal_batch = NULL;
	PixbufCachePixbufCacheBatch* _tmp0_;
	PixbufCachePixbufCacheBatch* master_batch = NULL;
	PixbufCachePixbufCacheBatch* _tmp1_;
	PixbufCachePixbufCacheBatch* _tmp2_;
	PixbufCachePixbufCacheBatch* _tmp3_;
	DataSource* next_source = NULL;
	DataSource* prev_source = NULL;
	DataSource* _tmp4_ = NULL;
	DataSource* _tmp5_ = NULL;
	gboolean _tmp6_;
	Photo* next = NULL;
	DataSource* _tmp7_;
	Photo* _tmp8_;
	Photo* prev = NULL;
	DataSource* _tmp9_;
	Photo* _tmp10_;
	PixbufCache* _tmp29_;
	PixbufCachePixbufCacheBatch* _tmp30_;
	PixbufCache* _tmp31_;
	PixbufCachePixbufCacheBatch* _tmp32_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (controller != NULL);
	g_return_if_fail (photo != NULL);
	_tmp0_ = pixbuf_cache_pixbuf_cache_batch_new ();
	normal_batch = _tmp0_;
	_tmp1_ = pixbuf_cache_pixbuf_cache_batch_new ();
	master_batch = _tmp1_;
	_tmp2_ = normal_batch;
	gee_multi_map_set ((GeeMultiMap*) _tmp2_, (gpointer) ((gintptr) BACKGROUND_JOB_JOB_PRIORITY_HIGHEST), photo);
	_tmp3_ = master_batch;
	gee_multi_map_set ((GeeMultiMap*) _tmp3_, (gpointer) ((gintptr) BACKGROUND_JOB_JOB_PRIORITY_LOW), photo);
	_tmp6_ = view_collection_get_immediate_neighbors (controller, (DataSource*) photo, &_tmp4_, &_tmp5_, PHOTO_TYPENAME);
	_g_object_unref0 (next_source);
	next_source = _tmp4_;
	_g_object_unref0 (prev_source);
	prev_source = _tmp5_;
	if (!_tmp6_) {
		_g_object_unref0 (prev_source);
		_g_object_unref0 (next_source);
		_g_object_unref0 (master_batch);
		_g_object_unref0 (normal_batch);
		return;
	}
	_tmp7_ = next_source;
	_tmp8_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, TYPE_PHOTO, Photo));
	next = _tmp8_;
	_tmp9_ = prev_source;
	_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, TYPE_PHOTO, Photo));
	prev = _tmp10_;
	{
		GeeIterator* _neighbor_source_it = NULL;
		GeeSet* _tmp11_;
		GeeSet* _tmp12_;
		GeeIterator* _tmp13_;
		GeeIterator* _tmp14_;
		_tmp11_ = view_collection_get_extended_neighbors (controller, (DataSource*) photo, PHOTO_TYPENAME);
		_tmp12_ = _tmp11_;
		_tmp13_ = gee_iterable_iterator ((GeeIterable*) _tmp12_);
		_tmp14_ = _tmp13_;
		_g_object_unref0 (_tmp12_);
		_neighbor_source_it = _tmp14_;
		while (TRUE) {
			GeeIterator* _tmp15_;
			DataSource* neighbor_source = NULL;
			GeeIterator* _tmp16_;
			gpointer _tmp17_;
			Photo* neighbor = NULL;
			DataSource* _tmp18_;
			Photo* _tmp19_;
			BackgroundJobJobPriority priority = 0;
			gboolean _tmp20_ = FALSE;
			Photo* _tmp21_;
			Photo* _tmp22_;
			PixbufCachePixbufCacheBatch* _tmp25_;
			Photo* _tmp26_;
			PixbufCachePixbufCacheBatch* _tmp27_;
			Photo* _tmp28_;
			_tmp15_ = _neighbor_source_it;
			if (!gee_iterator_next (_tmp15_)) {
				break;
			}
			_tmp16_ = _neighbor_source_it;
			_tmp17_ = gee_iterator_get (_tmp16_);
			neighbor_source = (DataSource*) _tmp17_;
			_tmp18_ = neighbor_source;
			_tmp19_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, TYPE_PHOTO, Photo));
			neighbor = _tmp19_;
			priority = BACKGROUND_JOB_JOB_PRIORITY_NORMAL;
			_tmp21_ = neighbor;
			_tmp22_ = next;
			if (data_source_equals ((DataSource*) _tmp21_, (DataSource*) _tmp22_)) {
				_tmp20_ = TRUE;
			} else {
				Photo* _tmp23_;
				Photo* _tmp24_;
				_tmp23_ = neighbor;
				_tmp24_ = prev;
				_tmp20_ = data_source_equals ((DataSource*) _tmp23_, (DataSource*) _tmp24_);
			}
			if (_tmp20_) {
				priority = BACKGROUND_JOB_JOB_PRIORITY_HIGH;
			}
			_tmp25_ = normal_batch;
			_tmp26_ = neighbor;
			gee_multi_map_set ((GeeMultiMap*) _tmp25_, (gpointer) ((gintptr) priority), _tmp26_);
			_tmp27_ = master_batch;
			_tmp28_ = neighbor;
			gee_multi_map_set ((GeeMultiMap*) _tmp27_, (gpointer) ((gintptr) BACKGROUND_JOB_JOB_PRIORITY_LOWEST), _tmp28_);
			_g_object_unref0 (neighbor);
			_g_object_unref0 (neighbor_source);
		}
		_g_object_unref0 (_neighbor_source_it);
	}
	_tmp29_ = self->priv->cache;
	_tmp30_ = normal_batch;
	pixbuf_cache_prefetch_batch (_tmp29_, _tmp30_, FALSE);
	_tmp31_ = self->priv->master_cache;
	_tmp32_ = master_batch;
	pixbuf_cache_prefetch_batch (_tmp31_, _tmp32_, FALSE);
	_g_object_unref0 (prev);
	_g_object_unref0 (next);
	_g_object_unref0 (prev_source);
	_g_object_unref0 (next_source);
	_g_object_unref0 (master_batch);
	_g_object_unref0 (normal_batch);
}

static void
editing_host_page_cancel_prefetch_neighbors (EditingHostPage* self,
                                             ViewCollection* old_controller,
                                             Photo* old_photo,
                                             ViewCollection* new_controller,
                                             Photo* new_photo)
{
	GeeSet* old_neighbors = NULL;
	GeeSet* _tmp0_;
	GeeSet* new_neighbors = NULL;
	GeeSet* _tmp1_;
	gboolean _tmp15_ = FALSE;
	GeeSet* _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (old_controller != NULL);
	g_return_if_fail (old_photo != NULL);
	g_return_if_fail (new_controller != NULL);
	g_return_if_fail (new_photo != NULL);
	_tmp0_ = view_collection_get_extended_neighbors (old_controller, (DataSource*) old_photo, PHOTO_TYPENAME);
	old_neighbors = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_SET, GeeSet);
	_tmp1_ = view_collection_get_extended_neighbors (new_controller, (DataSource*) new_photo, PHOTO_TYPENAME);
	new_neighbors = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_SET, GeeSet);
	{
		GeeIterator* _old_neighbor_it = NULL;
		GeeSet* _tmp2_;
		GeeIterator* _tmp3_;
		_tmp2_ = old_neighbors;
		_tmp3_ = gee_iterable_iterator ((GeeIterable*) _tmp2_);
		_old_neighbor_it = _tmp3_;
		while (TRUE) {
			GeeIterator* _tmp4_;
			Photo* old_neighbor = NULL;
			GeeIterator* _tmp5_;
			gpointer _tmp6_;
			gboolean _tmp7_ = FALSE;
			GeeSet* _tmp8_;
			Photo* _tmp9_;
			_tmp4_ = _old_neighbor_it;
			if (!gee_iterator_next (_tmp4_)) {
				break;
			}
			_tmp5_ = _old_neighbor_it;
			_tmp6_ = gee_iterator_get (_tmp5_);
			old_neighbor = (Photo*) _tmp6_;
			_tmp8_ = new_neighbors;
			_tmp9_ = old_neighbor;
			if (!gee_collection_contains ((GeeCollection*) _tmp8_, _tmp9_)) {
				Photo* _tmp10_;
				_tmp10_ = old_neighbor;
				_tmp7_ = !data_source_equals ((DataSource*) new_photo, (DataSource*) _tmp10_);
			} else {
				_tmp7_ = FALSE;
			}
			if (_tmp7_) {
				PixbufCache* _tmp11_;
				Photo* _tmp12_;
				PixbufCache* _tmp13_;
				Photo* _tmp14_;
				_tmp11_ = self->priv->cache;
				_tmp12_ = old_neighbor;
				pixbuf_cache_drop (_tmp11_, _tmp12_);
				_tmp13_ = self->priv->master_cache;
				_tmp14_ = old_neighbor;
				pixbuf_cache_drop (_tmp13_, _tmp14_);
			}
			_g_object_unref0 (old_neighbor);
		}
		_g_object_unref0 (_old_neighbor_it);
	}
	_tmp16_ = new_neighbors;
	if (!gee_collection_contains ((GeeCollection*) _tmp16_, old_photo)) {
		_tmp15_ = !data_source_equals ((DataSource*) new_photo, (DataSource*) old_photo);
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		PixbufCache* _tmp17_;
		PixbufCache* _tmp18_;
		_tmp17_ = self->priv->cache;
		pixbuf_cache_drop (_tmp17_, old_photo);
		_tmp18_ = self->priv->master_cache;
		pixbuf_cache_drop (_tmp18_, old_photo);
	}
	_g_object_unref0 (new_neighbors);
	_g_object_unref0 (old_neighbors);
}

static DataView*
editing_host_page_real_create_photo_view (EditingHostPage* self,
                                          DataSource* source)
{
	PhotoView* _tmp0_;
	DataView* result;
	g_return_val_if_fail (source != NULL, NULL);
	_tmp0_ = photo_view_new (G_TYPE_CHECK_INSTANCE_CAST (source, TYPE_PHOTO_SOURCE, PhotoSource));
	result = (DataView*) _tmp0_;
	return result;
}

DataView*
editing_host_page_create_photo_view (EditingHostPage* self,
                                     DataSource* source)
{
	EditingHostPageClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->create_photo_view) {
		return _klass_->create_photo_view (self, source);
	}
	return NULL;
}

static gboolean
editing_host_page_is_photo (EditingHostPage* self,
                            DataSource* source)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (source != NULL, FALSE);
	result = IS_PHOTO_SOURCE (source);
	return result;
}

static DataView*
_editing_host_page_create_photo_view_create_view (DataSource* source,
                                                  gpointer self)
{
	DataView* result;
	result = editing_host_page_create_photo_view ((EditingHostPage*) self, source);
	return result;
}

static gboolean
_editing_host_page_is_photo_create_view_predicate (DataSource* source,
                                                   gpointer self)
{
	gboolean result;
	result = editing_host_page_is_photo ((EditingHostPage*) self, source);
	return result;
}

static gpointer
_data_collection_ref0 (gpointer self)
{
	return self ? data_collection_ref (self) : NULL;
}

void
editing_host_page_display_copy_of (EditingHostPage* self,
                                   ViewCollection* controller,
                                   Photo* starting_photo)
{
	DataView* _tmp0_;
	DataView* _tmp1_;
	gboolean _tmp2_ = FALSE;
	ViewCollection* _tmp3_;
	ViewCollection* _tmp4_;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (controller != NULL);
	g_return_if_fail (starting_photo != NULL);
	_tmp0_ = view_collection_get_view_for_source (controller, (DataSource*) starting_photo);
	_tmp1_ = _tmp0_;
	_vala_assert (_tmp1_ != NULL, "controller.get_view_for_source (starting_photo) != null");
	_g_object_unref0 (_tmp1_);
	_tmp3_ = page_get_view ((Page*) self);
	_tmp4_ = _tmp3_;
	_tmp5_ = controller != _tmp4_;
	_data_collection_unref0 (_tmp4_);
	if (_tmp5_) {
		ViewCollection* _tmp6_;
		_tmp6_ = self->priv->parent_view;
		_tmp2_ = controller != _tmp6_;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		ViewCollection* _tmp7_;
		ViewCollection* _tmp8_;
		ViewCollection* _tmp9_;
		ViewCollection* _tmp10_;
		ViewCollection* _tmp11_;
		_tmp7_ = page_get_view ((Page*) self);
		_tmp8_ = _tmp7_;
		data_collection_clear ((DataCollection*) _tmp8_);
		_data_collection_unref0 (_tmp8_);
		_tmp9_ = page_get_view ((Page*) self);
		_tmp10_ = _tmp9_;
		view_collection_copy_into (_tmp10_, controller, _editing_host_page_create_photo_view_create_view, self, _editing_host_page_is_photo_create_view_predicate, self);
		_data_collection_unref0 (_tmp10_);
		_tmp11_ = _data_collection_ref0 (controller);
		_data_collection_unref0 (self->priv->parent_view);
		self->priv->parent_view = _tmp11_;
	}
	editing_host_page_replace_photo (self, starting_photo);
}

void
editing_host_page_display_mirror_of (EditingHostPage* self,
                                     ViewCollection* controller,
                                     Photo* starting_photo)
{
	DataView* _tmp0_;
	DataView* _tmp1_;
	gboolean _tmp2_ = FALSE;
	ViewCollection* _tmp3_;
	ViewCollection* _tmp4_;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (controller != NULL);
	g_return_if_fail (starting_photo != NULL);
	_tmp0_ = view_collection_get_view_for_source (controller, (DataSource*) starting_photo);
	_tmp1_ = _tmp0_;
	_vala_assert (_tmp1_ != NULL, "controller.get_view_for_source (starting_photo) != null");
	_g_object_unref0 (_tmp1_);
	_tmp3_ = page_get_view ((Page*) self);
	_tmp4_ = _tmp3_;
	_tmp5_ = controller != _tmp4_;
	_data_collection_unref0 (_tmp4_);
	if (_tmp5_) {
		ViewCollection* _tmp6_;
		_tmp6_ = self->priv->parent_view;
		_tmp2_ = controller != _tmp6_;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		ViewCollection* _tmp7_;
		ViewCollection* _tmp8_;
		ViewCollection* _tmp9_;
		ViewCollection* _tmp10_;
		ViewCollection* _tmp11_;
		_tmp7_ = page_get_view ((Page*) self);
		_tmp8_ = _tmp7_;
		data_collection_clear ((DataCollection*) _tmp8_);
		_data_collection_unref0 (_tmp8_);
		_tmp9_ = page_get_view ((Page*) self);
		_tmp10_ = _tmp9_;
		view_collection_mirror (_tmp10_, controller, _editing_host_page_create_photo_view_create_view, self, _editing_host_page_is_photo_create_view_predicate, self);
		_data_collection_unref0 (_tmp10_);
		_tmp11_ = _data_collection_ref0 (controller);
		_data_collection_unref0 (self->priv->parent_view);
		self->priv->parent_view = _tmp11_;
	}
	editing_host_page_replace_photo (self, starting_photo);
}

static void
editing_host_page_real_update_ui (EditingHostPage* self,
                                  gboolean missing)
{
	gboolean sensitivity = FALSE;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkToggleButton* _tmp2_;
	GtkToggleButton* _tmp3_;
	GtkToggleButton* _tmp4_;
	GtkToggleButton* _tmp5_;
	GtkToggleButton* _tmp6_;
	SliderAssembly* _tmp7_;
	Dimensions _tmp8_ = {0};
	sensitivity = !missing;
	_tmp0_ = self->priv->flip_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, sensitivity);
	_tmp1_ = self->rotate_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, sensitivity);
	_tmp2_ = self->priv->crop_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp2_, sensitivity);
	_tmp3_ = self->priv->straighten_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp3_, sensitivity);
	_tmp4_ = self->priv->redeye_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, sensitivity);
	_tmp5_ = self->priv->adjust_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp5_, sensitivity);
	_tmp6_ = self->enhance_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp6_, sensitivity);
	_tmp7_ = self->priv->zoom_assembly;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp7_, sensitivity);
	dimensions_init (&_tmp8_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp8_, FALSE);
}

void
editing_host_page_update_ui (EditingHostPage* self,
                             gboolean missing)
{
	EditingHostPageClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->update_ui) {
		_klass_->update_ui (self, missing);
	}
}

static void
editing_host_page_real_notify_photo_backing_missing (EditingHostPage* self,
                                                     Photo* photo,
                                                     gboolean missing)
{
	g_return_if_fail (photo != NULL);
}

void
editing_host_page_notify_photo_backing_missing (EditingHostPage* self,
                                                Photo* photo,
                                                gboolean missing)
{
	EditingHostPageClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->notify_photo_backing_missing) {
		_klass_->notify_photo_backing_missing (self, photo, missing);
	}
}

static void
editing_host_page_draw_message (EditingHostPage* self,
                                const gchar* message)
{
	PangoLayout* pango_layout = NULL;
	PangoLayout* _tmp0_;
	gint text_width = 0;
	gint text_height = 0;
	PangoLayout* _tmp1_;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp4_ = {0};
	gint x = 0;
	GtkAllocation _tmp5_;
	gint _tmp6_ = 0;
	gint y = 0;
	GtkAllocation _tmp7_;
	gint _tmp8_ = 0;
	PangoLayout* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_tmp0_ = gtk_widget_create_pango_layout ((GtkWidget*) self, message);
	pango_layout = _tmp0_;
	_tmp1_ = pango_layout;
	pango_layout_get_pixel_size (_tmp1_, &_tmp2_, &_tmp3_);
	text_width = _tmp2_;
	text_height = _tmp3_;
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp4_);
	allocation = _tmp4_;
	_tmp5_ = allocation;
	x = _tmp5_.width - text_width;
	if (x > 0) {
		_tmp6_ = x / 2;
	} else {
		_tmp6_ = 0;
	}
	x = _tmp6_;
	_tmp7_ = allocation;
	y = _tmp7_.height - text_height;
	if (y > 0) {
		_tmp8_ = y / 2;
	} else {
		_tmp8_ = 0;
	}
	y = _tmp8_;
	_tmp9_ = pango_layout;
	single_photo_page_paint_text ((SinglePhotoPage*) self, _tmp9_, x, y);
	_g_object_unref0 (pango_layout);
}

void
editing_host_page_set_photo_missing (EditingHostPage* self,
                                     gboolean missing)
{
	Photo* photo = NULL;
	Photo* _tmp0_;
	Photo* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	if (self->priv->photo_missing == missing) {
		return;
	}
	self->priv->photo_missing = missing;
	_tmp0_ = editing_host_page_get_photo (self);
	photo = _tmp0_;
	_tmp1_ = photo;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (photo);
		return;
	}
	editing_host_page_update_ui (self, missing);
	if (self->priv->photo_missing) {
		{
			GdkPixbuf* pixbuf = NULL;
			Photo* _tmp2_;
			Scaling _tmp3_ = {0};
			GdkPixbuf* _tmp4_;
			GdkPixbuf* _tmp5_;
			GdkPixbuf* _tmp6_;
			GdkPixbuf* _tmp7_;
			GdkPixbuf* _tmp8_;
			GdkPixbuf* _tmp9_;
			Photo* _tmp10_;
			Dimensions _tmp11_ = {0};
			_tmp2_ = photo;
			single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp3_);
			_tmp4_ = media_source_get_preview_pixbuf ((MediaSource*) _tmp2_, &_tmp3_, &_inner_error0_);
			pixbuf = _tmp4_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp5_ = pixbuf;
			_tmp6_ = pixbuf;
			_tmp7_ = pixbuf;
			_tmp8_ = gdk_pixbuf_composite_color_simple (_tmp5_, gdk_pixbuf_get_width (_tmp6_), gdk_pixbuf_get_height (_tmp7_), GDK_INTERP_NEAREST, 100, 2, (guint32) 0, (guint32) 0);
			_g_object_unref0 (pixbuf);
			pixbuf = _tmp8_;
			_tmp9_ = pixbuf;
			_tmp10_ = photo;
			media_source_get_dimensions ((MediaSource*) _tmp10_, PHOTO_EXCEPTION_NONE, &_tmp11_);
			single_photo_page_set_pixbuf ((SinglePhotoPage*) self, _tmp9_, &_tmp11_, NULL);
			_g_object_unref0 (pixbuf);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* err = NULL;
			GError* _tmp12_;
			const gchar* _tmp13_;
			err = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp12_ = err;
			_tmp13_ = _tmp12_->message;
			g_warning ("EditingHostPage.vala:820: %s", _tmp13_);
			_g_error_free0 (err);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (photo);
			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_object_unref0 (photo);
}

gboolean
editing_host_page_get_photo_missing (EditingHostPage* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->photo_missing;
	return result;
}

static gboolean
editing_host_page_real_confirm_replace_photo (EditingHostPage* self,
                                              Photo* old_photo,
                                              Photo* new_photo)
{
	gboolean result;
	g_return_val_if_fail (new_photo != NULL, FALSE);
	result = TRUE;
	return result;
}

gboolean
editing_host_page_confirm_replace_photo (EditingHostPage* self,
                                         Photo* old_photo,
                                         Photo* new_photo)
{
	EditingHostPageClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->confirm_replace_photo) {
		return _klass_->confirm_replace_photo (self, old_photo, new_photo);
	}
	return FALSE;
}

static GdkPixbuf*
editing_host_page_get_zoom_pixbuf (EditingHostPage* self,
                                   Photo* new_photo)
{
	GdkPixbuf* pixbuf = NULL;
	PixbufCache* _tmp0_;
	GdkPixbuf* _tmp1_;
	GdkPixbuf* _tmp2_;
	GdkPixbuf* _tmp9_;
	GError* _inner_error0_ = NULL;
	GdkPixbuf* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (new_photo != NULL, NULL);
	_tmp0_ = self->priv->cache;
	_tmp1_ = pixbuf_cache_get_ready_pixbuf (_tmp0_, new_photo);
	pixbuf = _tmp1_;
	_tmp2_ = pixbuf;
	if (_tmp2_ == NULL) {
		{
			GdkPixbuf* _tmp3_ = NULL;
			Scaling _tmp4_ = {0};
			GdkPixbuf* _tmp5_;
			GdkPixbuf* _tmp6_;
			single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp4_);
			_tmp5_ = media_source_get_preview_pixbuf ((MediaSource*) new_photo, &_tmp4_, &_inner_error0_);
			_tmp3_ = _tmp5_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp6_ = _tmp3_;
			_tmp3_ = NULL;
			_g_object_unref0 (pixbuf);
			pixbuf = _tmp6_;
			_g_object_unref0 (_tmp3_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* err = NULL;
			GError* _tmp7_;
			const gchar* _tmp8_;
			err = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp7_ = err;
			_tmp8_ = _tmp7_->message;
			g_warning ("EditingHostPage.vala:839: %s", _tmp8_);
			_g_error_free0 (err);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (pixbuf);
			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;
		}
	}
	_tmp9_ = pixbuf;
	if (_tmp9_ == NULL) {
		GtkIconTheme* icon_theme = NULL;
		GdkWindow* _tmp10_;
		GdkScreen* _tmp11_;
		GtkIconTheme* _tmp12_;
		_tmp10_ = gtk_widget_get_window ((GtkWidget*) self);
		_tmp11_ = gdk_window_get_screen (_tmp10_);
		_tmp12_ = gtk_icon_theme_get_for_screen (_tmp11_);
		icon_theme = _tmp12_;
		{
			GdkPixbuf* _tmp13_ = NULL;
			GtkIconTheme* _tmp14_;
			GdkPixbuf* _tmp15_;
			GdkPixbuf* _tmp16_;
			Scaling _tmp17_ = {0};
			GdkPixbuf* _tmp18_;
			GdkPixbuf* _tmp19_;
			GdkPixbuf* _tmp20_;
			_tmp14_ = icon_theme;
			_tmp15_ = gtk_icon_theme_load_icon (_tmp14_, "image-missing", (gint) GTK_ICON_SIZE_DIALOG, GTK_ICON_LOOKUP_GENERIC_FALLBACK, &_inner_error0_);
			_tmp13_ = _tmp15_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
			_tmp16_ = _tmp13_;
			_tmp13_ = NULL;
			_g_object_unref0 (pixbuf);
			pixbuf = _tmp16_;
			single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp17_);
			_tmp18_ = pixbuf;
			_tmp19_ = scaling_perform_on_pixbuf (&_tmp17_, _tmp18_, GDK_INTERP_NEAREST, TRUE);
			_tmp20_ = _tmp19_;
			_g_object_unref0 (_tmp20_);
			_g_object_unref0 (_tmp13_);
		}
		goto __finally1;
		__catch1_g_error:
		{
			GError* e = NULL;
			GError* _tmp21_;
			const gchar* _tmp22_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp21_ = e;
			_tmp22_ = _tmp21_->message;
			g_critical ("EditingHostPage.vala:849: %s", _tmp22_);
			_g_error_free0 (e);
		}
		__finally1:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (pixbuf);
			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;
		}
	}
	result = pixbuf;
	return result;
}

static void
editing_host_page_replace_photo (EditingHostPage* self,
                                 Photo* new_photo)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	Photo* _tmp2_;
	Photo* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	Dimensions _tmp15_ = {0};
	Photo* old_photo = NULL;
	Photo* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	GFile* _tmp19_;
	GFile* _tmp20_;
	Photo* _tmp21_;
	GdkPixbuf* _tmp27_;
	GdkPixbuf* _tmp28_;
	ZoomBuffer* _tmp29_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (new_photo != NULL);
	_tmp2_ = editing_host_page_get_photo (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = data_source_equals ((DataSource*) new_photo, (DataSource*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	if (_tmp4_) {
		_tmp1_ = !self->priv->pixbuf_dirty;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = !self->priv->photo_missing;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GdkPixbuf* _tmp5_;
		GdkPixbuf* _tmp6_;
		ZoomBuffer* _tmp7_;
		_tmp5_ = editing_host_page_get_zoom_pixbuf (self, new_photo);
		_tmp6_ = _tmp5_;
		_tmp7_ = zoom_buffer_new ((SinglePhotoPage*) self, new_photo, _tmp6_);
		_g_object_unref0 (self->priv->zoom_buffer);
		self->priv->zoom_buffer = _tmp7_;
		_g_object_unref0 (_tmp6_);
		return;
	}
	if (editing_host_page_has_photo (self)) {
		Photo* _tmp10_;
		Photo* _tmp11_;
		_tmp10_ = editing_host_page_get_photo (self);
		_tmp11_ = _tmp10_;
		_tmp9_ = !data_source_equals ((DataSource*) new_photo, (DataSource*) _tmp11_);
		_g_object_unref0 (_tmp11_);
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		_tmp8_ = editing_host_page_confirm_replace_photo != NULL;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		Photo* _tmp12_;
		Photo* _tmp13_;
		gboolean _tmp14_;
		_tmp12_ = editing_host_page_get_photo (self);
		_tmp13_ = _tmp12_;
		_tmp14_ = !editing_host_page_confirm_replace_photo (self, _tmp13_, new_photo);
		_g_object_unref0 (_tmp13_);
		if (_tmp14_) {
			return;
		}
	}
	dimensions_init (&_tmp15_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp15_, FALSE);
	_tmp16_ = editing_host_page_get_photo (self);
	old_photo = _tmp16_;
	editing_host_page_set_photo (self, new_photo);
	_tmp17_ = data_object_get_name ((DataObject*) new_photo);
	_tmp18_ = _tmp17_;
	page_set_page_name ((Page*) self, _tmp18_);
	_g_free0 (_tmp18_);
	_g_object_unref0 (self->priv->swapped);
	self->priv->swapped = NULL;
	_tmp19_ = media_source_get_file ((MediaSource*) new_photo);
	_tmp20_ = _tmp19_;
	editing_host_page_set_photo_missing (self, !g_file_query_exists (_tmp20_, NULL));
	_g_object_unref0 (_tmp20_);
	self->priv->pixbuf_dirty = TRUE;
	editing_host_page_rebuild_caches (self, "replace_photo");
	_tmp21_ = old_photo;
	if (_tmp21_ != NULL) {
		ViewCollection* _tmp22_;
		ViewCollection* _tmp23_;
		Photo* _tmp24_;
		ViewCollection* _tmp25_;
		ViewCollection* _tmp26_;
		_tmp22_ = page_get_view ((Page*) self);
		_tmp23_ = _tmp22_;
		_tmp24_ = old_photo;
		_tmp25_ = page_get_view ((Page*) self);
		_tmp26_ = _tmp25_;
		editing_host_page_cancel_prefetch_neighbors (self, _tmp23_, _tmp24_, _tmp26_, new_photo);
		_data_collection_unref0 (_tmp26_);
		_data_collection_unref0 (_tmp23_);
	}
	single_photo_page_cancel_zoom ((SinglePhotoPage*) self);
	_tmp27_ = editing_host_page_get_zoom_pixbuf (self, new_photo);
	_tmp28_ = _tmp27_;
	_tmp29_ = zoom_buffer_new ((SinglePhotoPage*) self, new_photo, _tmp28_);
	_g_object_unref0 (self->priv->zoom_buffer);
	self->priv->zoom_buffer = _tmp29_;
	_g_object_unref0 (_tmp28_);
	editing_host_page_quick_update_pixbuf (self);
	editing_host_page_refresh_caches (self, "replace_photo");
	_g_object_unref0 (old_photo);
}

static void
editing_host_page_real_cancel_zoom (SinglePhotoPage* base)
{
	EditingHostPage * self;
	SliderAssembly* _tmp0_;
	guint _tmp1_;
	SliderAssembly* _tmp2_;
	Photo* _tmp3_;
	Photo* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp11_ = FALSE;
	GtkDrawingArea* _tmp12_;
	self = (EditingHostPage*) base;
	SINGLE_PHOTO_PAGE_CLASS (editing_host_page_parent_class)->cancel_zoom (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage));
	_tmp0_ = self->priv->zoom_assembly;
	g_signal_parse_name ("value-changed", TYPE_SLIDER_ASSEMBLY, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed, self);
	_tmp2_ = self->priv->zoom_assembly;
	g_signal_connect_object (_tmp2_, "value-changed", (GCallback) _editing_host_page_on_zoom_assembly_value_changed_slider_assembly_value_changed, self, 0);
	_tmp3_ = editing_host_page_get_photo (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_ != NULL;
	_g_object_unref0 (_tmp4_);
	if (_tmp5_) {
		Photo* _tmp6_;
		Photo* _tmp7_;
		Dimensions _tmp8_ = {0};
		Dimensions _tmp9_ = {0};
		ZoomState _tmp10_ = {0};
		_tmp6_ = editing_host_page_get_photo (self);
		_tmp7_ = _tmp6_;
		media_source_get_dimensions ((MediaSource*) _tmp7_, PHOTO_EXCEPTION_NONE, &_tmp8_);
		single_photo_page_get_surface_dim ((SinglePhotoPage*) self, &_tmp9_);
		zoom_state_init (&_tmp10_, &_tmp8_, &_tmp9_, 0.0, NULL);
		single_photo_page_set_zoom_state ((SinglePhotoPage*) self, &_tmp10_);
		_g_object_unref0 (_tmp7_);
	}
	_tmp12_ = ((SinglePhotoPage*) self)->canvas;
	if (_tmp12_ != NULL) {
		GtkDrawingArea* _tmp13_;
		GdkWindow* _tmp14_;
		_tmp13_ = ((SinglePhotoPage*) self)->canvas;
		_tmp14_ = gtk_widget_get_window ((GtkWidget*) _tmp13_);
		_tmp11_ = _tmp14_ != NULL;
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		page_set_page_cursor ((Page*) self, GDK_LEFT_PTR);
	}
	single_photo_page_repaint ((SinglePhotoPage*) self, NULL);
}

static void
editing_host_page_quick_update_pixbuf (EditingHostPage* self)
{
	GdkPixbuf* pixbuf = NULL;
	PixbufCache* _tmp0_;
	Photo* _tmp1_;
	Photo* _tmp2_;
	GdkPixbuf* _tmp3_;
	GdkPixbuf* _tmp4_;
	GdkPixbuf* _tmp5_;
	Scaling scaling = {0};
	Scaling _tmp10_ = {0};
	Photo* _tmp11_;
	Photo* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	PixbufCache* _tmp28_;
	Photo* _tmp29_;
	Photo* _tmp30_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->cache;
	_tmp1_ = editing_host_page_get_photo (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = pixbuf_cache_get_ready_pixbuf (_tmp0_, _tmp2_);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp2_);
	pixbuf = _tmp4_;
	_tmp5_ = pixbuf;
	if (_tmp5_ != NULL) {
		GdkPixbuf* _tmp6_;
		Photo* _tmp7_;
		Photo* _tmp8_;
		Dimensions _tmp9_ = {0};
		_tmp6_ = pixbuf;
		_tmp7_ = editing_host_page_get_photo (self);
		_tmp8_ = _tmp7_;
		media_source_get_dimensions ((MediaSource*) _tmp8_, PHOTO_EXCEPTION_NONE, &_tmp9_);
		single_photo_page_set_pixbuf ((SinglePhotoPage*) self, _tmp6_, &_tmp9_, NULL);
		_g_object_unref0 (_tmp8_);
		self->priv->pixbuf_dirty = FALSE;
		_g_object_unref0 (pixbuf);
		return;
	}
	single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp10_);
	scaling = _tmp10_;
	_tmp11_ = editing_host_page_get_photo (self);
	_tmp12_ = _tmp11_;
	_tmp13_ = data_object_to_string ((DataObject*) _tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = scaling_to_string (&scaling);
	_tmp16_ = _tmp15_;
	g_debug ("EditingHostPage.vala:933: Using progressive load for %s (%s)", _tmp14_, _tmp16_);
	_g_free0 (_tmp16_);
	_g_free0 (_tmp14_);
	_g_object_unref0 (_tmp12_);
	{
		GdkPixbuf* _tmp17_ = NULL;
		Photo* _tmp18_;
		Photo* _tmp19_;
		Scaling _tmp20_;
		GdkPixbuf* _tmp21_;
		GdkPixbuf* _tmp22_;
		Photo* _tmp23_;
		Photo* _tmp24_;
		Dimensions _tmp25_ = {0};
		_tmp18_ = editing_host_page_get_photo (self);
		_tmp19_ = _tmp18_;
		_tmp20_ = scaling;
		_tmp21_ = media_source_get_preview_pixbuf ((MediaSource*) _tmp19_, &_tmp20_, &_inner_error0_);
		_tmp22_ = _tmp21_;
		_g_object_unref0 (_tmp19_);
		_tmp17_ = _tmp22_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp23_ = editing_host_page_get_photo (self);
		_tmp24_ = _tmp23_;
		media_source_get_dimensions ((MediaSource*) _tmp24_, PHOTO_EXCEPTION_NONE, &_tmp25_);
		single_photo_page_set_pixbuf ((SinglePhotoPage*) self, _tmp17_, &_tmp25_, NULL);
		_g_object_unref0 (_tmp24_);
		_g_object_unref0 (_tmp17_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp26_;
		const gchar* _tmp27_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp26_ = err;
		_tmp27_ = _tmp26_->message;
		g_warning ("EditingHostPage.vala:940: %s", _tmp27_);
		_g_error_free0 (err);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (pixbuf);
		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;
	}
	_tmp28_ = self->priv->cache;
	_tmp29_ = editing_host_page_get_photo (self);
	_tmp30_ = _tmp29_;
	pixbuf_cache_prefetch (_tmp28_, _tmp30_, BACKGROUND_JOB_JOB_PRIORITY_HIGHEST, FALSE);
	_g_object_unref0 (_tmp30_);
	self->priv->pixbuf_dirty = FALSE;
	_g_object_unref0 (pixbuf);
}

static gboolean
editing_host_page_update_pixbuf (EditingHostPage* self)
{
	Photo* photo = NULL;
	Photo* _tmp0_;
	Photo* _tmp1_;
	GdkPixbuf* pixbuf = NULL;
	Dimensions max_dim = {0};
	Photo* _tmp2_;
	Dimensions _tmp3_ = {0};
	gboolean _tmp25_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = editing_host_page_get_photo (self);
	photo = _tmp0_;
	_tmp1_ = photo;
	if (_tmp1_ == NULL) {
		result = FALSE;
		_g_object_unref0 (photo);
		return result;
	}
	pixbuf = NULL;
	_tmp2_ = photo;
	media_source_get_dimensions ((MediaSource*) _tmp2_, PHOTO_EXCEPTION_NONE, &_tmp3_);
	max_dim = _tmp3_;
	{
		Dimensions tool_pixbuf_dim = {0};
		Dimensions _tmp4_ = {0};
		EditingToolsEditingTool* _tmp5_;
		GdkPixbuf* _tmp13_;
		_tmp4_.width = 0;
		tool_pixbuf_dim = _tmp4_;
		_tmp5_ = self->priv->current_tool;
		if (_tmp5_ != NULL) {
			GdkPixbuf* _tmp6_ = NULL;
			EditingToolsEditingTool* _tmp7_;
			Scaling _tmp8_ = {0};
			Photo* _tmp9_;
			Dimensions _tmp10_ = {0};
			GdkPixbuf* _tmp11_;
			GdkPixbuf* _tmp12_;
			_tmp7_ = self->priv->current_tool;
			single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp8_);
			_tmp9_ = photo;
			_tmp11_ = editing_tools_editing_tool_get_display_pixbuf (_tmp7_, &_tmp8_, _tmp9_, &_tmp10_, &_inner_error0_);
			tool_pixbuf_dim = _tmp10_;
			_tmp6_ = _tmp11_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp12_ = _tmp6_;
			_tmp6_ = NULL;
			_g_object_unref0 (pixbuf);
			pixbuf = _tmp12_;
			_g_object_unref0 (_tmp6_);
		}
		_tmp13_ = pixbuf;
		if (_tmp13_ != NULL) {
			Dimensions _tmp14_;
			_tmp14_ = tool_pixbuf_dim;
			max_dim = _tmp14_;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp15_;
		const gchar* _tmp16_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp15_ = err;
		_tmp16_ = _tmp15_->message;
		g_warning ("EditingHostPage.vala:970: %s", _tmp16_);
		editing_host_page_set_photo_missing (self, TRUE);
		_g_error_free0 (err);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp17_ = FALSE;
		_g_object_unref0 (pixbuf);
		_g_object_unref0 (photo);
		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_;
	}
	if (!self->priv->photo_missing) {
		GdkPixbuf* _tmp18_;
		GdkPixbuf* _tmp22_;
		_tmp18_ = pixbuf;
		if (_tmp18_ == NULL) {
			PixbufCache* _tmp19_;
			Photo* _tmp20_;
			GdkPixbuf* _tmp21_;
			_tmp19_ = self->priv->cache;
			_tmp20_ = photo;
			_tmp21_ = pixbuf_cache_get_ready_pixbuf (_tmp19_, _tmp20_);
			_g_object_unref0 (pixbuf);
			pixbuf = _tmp21_;
		}
		_tmp22_ = pixbuf;
		if (_tmp22_ == NULL) {
			PixbufCache* _tmp23_;
			Photo* _tmp24_;
			_tmp23_ = self->priv->cache;
			_tmp24_ = photo;
			pixbuf_cache_prefetch (_tmp23_, _tmp24_, BACKGROUND_JOB_JOB_PRIORITY_NORMAL, FALSE);
		}
	}
	if (!self->priv->photo_missing) {
		GdkPixbuf* _tmp26_;
		_tmp26_ = pixbuf;
		_tmp25_ = _tmp26_ != NULL;
	} else {
		_tmp25_ = FALSE;
	}
	if (_tmp25_) {
		GdkPixbuf* _tmp27_;
		Dimensions _tmp28_;
		_tmp27_ = pixbuf;
		_tmp28_ = max_dim;
		single_photo_page_set_pixbuf ((SinglePhotoPage*) self, _tmp27_, &_tmp28_, NULL);
		self->priv->pixbuf_dirty = FALSE;
	}
	result = FALSE;
	_g_object_unref0 (pixbuf);
	_g_object_unref0 (photo);
	return result;
}

static void
editing_host_page_real_on_resize_finished (Page* base,
                                           GdkRectangle* rect)
{
	EditingHostPage * self;
	self = (EditingHostPage*) base;
	g_return_if_fail (rect != NULL);
	editing_host_page_rebuild_caches (self, "on_resize_finished");
	self->priv->pixbuf_dirty = TRUE;
	editing_host_page_update_pixbuf (self);
}

static void
editing_host_page_on_viewport_resized (EditingHostPage* self)
{
	g_return_if_fail (self != NULL);
	editing_host_page_rebuild_caches (self, "on_viewport_resized");
	self->priv->pixbuf_dirty = TRUE;
	editing_host_page_update_pixbuf (self);
}

static void
editing_host_page_real_update_actions (Page* base,
                                       gint selected_count,
                                       gint count)
{
	EditingHostPage * self;
	gboolean multiple_photos = FALSE;
	ViewCollection* _tmp0_;
	ViewCollection* _tmp1_;
	gboolean _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	Photo* photo = NULL;
	Photo* _tmp5_;
	Scaling scaling = {0};
	Scaling _tmp6_ = {0};
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	Photo* _tmp10_;
	GtkButton* _tmp13_;
	gboolean _tmp14_ = FALSE;
	gboolean _tmp15_ = FALSE;
	Photo* _tmp16_;
	GtkToggleButton* _tmp19_;
	gboolean _tmp20_ = FALSE;
	gboolean _tmp21_ = FALSE;
	Photo* _tmp22_;
	GtkToggleButton* _tmp25_;
	gboolean _tmp26_ = FALSE;
	gboolean _tmp27_ = FALSE;
	Photo* _tmp28_;
	GtkToggleButton* _tmp31_;
	gboolean _tmp32_ = FALSE;
	gboolean _tmp33_ = FALSE;
	Photo* _tmp34_;
	GtkToggleButton* _tmp36_;
	gboolean _tmp37_ = FALSE;
	gboolean _tmp38_ = FALSE;
	Photo* _tmp39_;
	GtkToggleButton* _tmp42_;
	self = (EditingHostPage*) base;
	_tmp0_ = page_get_view ((Page*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = view_collection_get_sources_of_type_count (_tmp1_, TYPE_PHOTO) > 1;
	_data_collection_unref0 (_tmp1_);
	multiple_photos = _tmp2_;
	_tmp3_ = self->priv->prev_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp3_, multiple_photos);
	_tmp4_ = self->priv->next_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, multiple_photos);
	_tmp5_ = editing_host_page_get_photo (self);
	photo = _tmp5_;
	single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp6_);
	scaling = _tmp6_;
	_tmp10_ = photo;
	if (_tmp10_ != NULL) {
		_tmp9_ = !self->priv->photo_missing;
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		Photo* _tmp11_;
		_tmp11_ = photo;
		_tmp8_ = photo_check_can_rotate (_tmp11_);
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		Photo* _tmp12_;
		_tmp12_ = photo;
		_tmp7_ = editing_host_page_is_rotate_available (self, _tmp12_);
	} else {
		_tmp7_ = FALSE;
	}
	_tmp13_ = self->rotate_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp13_, _tmp7_);
	_tmp16_ = photo;
	if (_tmp16_ != NULL) {
		_tmp15_ = !self->priv->photo_missing;
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		Photo* _tmp17_;
		Scaling _tmp18_;
		_tmp17_ = photo;
		_tmp18_ = scaling;
		_tmp14_ = editing_tools_crop_tool_is_available (_tmp17_, &_tmp18_);
	} else {
		_tmp14_ = FALSE;
	}
	_tmp19_ = self->priv->crop_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp19_, _tmp14_);
	_tmp22_ = photo;
	if (_tmp22_ != NULL) {
		_tmp21_ = !self->priv->photo_missing;
	} else {
		_tmp21_ = FALSE;
	}
	if (_tmp21_) {
		Photo* _tmp23_;
		Scaling _tmp24_;
		_tmp23_ = photo;
		_tmp24_ = scaling;
		_tmp20_ = editing_tools_redeye_tool_is_available (_tmp23_, &_tmp24_);
	} else {
		_tmp20_ = FALSE;
	}
	_tmp25_ = self->priv->redeye_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp25_, _tmp20_);
	_tmp28_ = photo;
	if (_tmp28_ != NULL) {
		_tmp27_ = !self->priv->photo_missing;
	} else {
		_tmp27_ = FALSE;
	}
	if (_tmp27_) {
		Photo* _tmp29_;
		Scaling _tmp30_;
		_tmp29_ = photo;
		_tmp30_ = scaling;
		_tmp26_ = editing_tools_adjust_tool_is_available (_tmp29_, &_tmp30_);
	} else {
		_tmp26_ = FALSE;
	}
	_tmp31_ = self->priv->adjust_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp31_, _tmp26_);
	_tmp34_ = photo;
	if (_tmp34_ != NULL) {
		_tmp33_ = !self->priv->photo_missing;
	} else {
		_tmp33_ = FALSE;
	}
	if (_tmp33_) {
		Photo* _tmp35_;
		_tmp35_ = photo;
		_tmp32_ = editing_host_page_is_enhance_available (self, _tmp35_);
	} else {
		_tmp32_ = FALSE;
	}
	_tmp36_ = self->enhance_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp36_, _tmp32_);
	_tmp39_ = photo;
	if (_tmp39_ != NULL) {
		_tmp38_ = !self->priv->photo_missing;
	} else {
		_tmp38_ = FALSE;
	}
	if (_tmp38_) {
		Photo* _tmp40_;
		Scaling _tmp41_;
		_tmp40_ = photo;
		_tmp41_ = scaling;
		_tmp37_ = editing_tools_straighten_tool_is_available (_tmp40_, &_tmp41_);
	} else {
		_tmp37_ = FALSE;
	}
	_tmp42_ = self->priv->straighten_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp42_, _tmp37_);
	PAGE_CLASS (editing_host_page_parent_class)->update_actions ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), selected_count, count);
	_g_object_unref0 (photo);
}

static gboolean
editing_host_page_real_on_shift_pressed (Page* base,
                                         GdkEventKey* event)
{
	EditingHostPage * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	EditingToolsEditingTool* _tmp2_;
	gboolean result;
	self = (EditingHostPage*) base;
	_tmp2_ = self->priv->current_tool;
	if (_tmp2_ == NULL) {
		_tmp1_ = !page_get_ctrl_pressed ((Page*) self);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = !page_get_alt_pressed ((Page*) self);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		editing_host_page_swap_in_original (self);
	}
	result = PAGE_CLASS (editing_host_page_parent_class)->on_shift_pressed ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), event);
	return result;
}

static gboolean
editing_host_page_real_on_shift_released (Page* base,
                                          GdkEventKey* event)
{
	EditingHostPage * self;
	EditingToolsEditingTool* _tmp0_;
	gboolean result;
	self = (EditingHostPage*) base;
	_tmp0_ = self->priv->current_tool;
	if (_tmp0_ == NULL) {
		editing_host_page_swap_out_original (self);
	}
	result = PAGE_CLASS (editing_host_page_parent_class)->on_shift_released ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), event);
	return result;
}

static gboolean
editing_host_page_real_on_alt_pressed (Page* base,
                                       GdkEventKey* event)
{
	EditingHostPage * self;
	EditingToolsEditingTool* _tmp0_;
	gboolean result;
	self = (EditingHostPage*) base;
	_tmp0_ = self->priv->current_tool;
	if (_tmp0_ == NULL) {
		editing_host_page_swap_out_original (self);
	}
	result = PAGE_CLASS (editing_host_page_parent_class)->on_alt_pressed ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), event);
	return result;
}

static gboolean
editing_host_page_real_on_alt_released (Page* base,
                                        GdkEventKey* event)
{
	EditingHostPage * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	EditingToolsEditingTool* _tmp2_;
	gboolean result;
	self = (EditingHostPage*) base;
	_tmp2_ = self->priv->current_tool;
	if (_tmp2_ == NULL) {
		_tmp1_ = page_get_shift_pressed ((Page*) self);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = !page_get_ctrl_pressed ((Page*) self);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		editing_host_page_swap_in_original (self);
	}
	result = PAGE_CLASS (editing_host_page_parent_class)->on_alt_released ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), event);
	return result;
}

static void
editing_host_page_swap_in_original (EditingHostPage* self)
{
	GdkPixbuf* original = NULL;
	Photo* _tmp0_;
	Photo* _tmp1_;
	Photo* _tmp2_;
	Photo* _tmp3_;
	GdkPixbuf* _tmp4_;
	GdkPixbuf* _tmp5_;
	GdkPixbuf* _tmp6_;
	GdkPixbuf* _tmp7_;
	GdkPixbuf* _tmp8_;
	SliderAssembly* _tmp9_;
	gdouble _tmp10_;
	gdouble _tmp11_;
	GdkPixbuf* _tmp12_;
	Photo* _tmp13_;
	Photo* _tmp14_;
	Dimensions _tmp15_ = {0};
	g_return_if_fail (self != NULL);
	_tmp0_ = editing_host_page_get_photo (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = editing_host_page_get_photo (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = photo_get_prefetched_copy (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = orientation_rotate_pixbuf (photo_get_original_orientation (_tmp1_), _tmp5_);
	_g_object_unref0 (original);
	original = _tmp6_;
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	_tmp7_ = original;
	if (_tmp7_ == NULL) {
		_g_object_unref0 (original);
		return;
	}
	_tmp8_ = single_photo_page_get_unscaled_pixbuf ((SinglePhotoPage*) self);
	_g_object_unref0 (self->priv->swapped);
	self->priv->swapped = _tmp8_;
	_tmp9_ = self->priv->zoom_assembly;
	_tmp10_ = slider_assembly_get_slider_value (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_ != 0.0) {
		single_photo_page_save_zoom_state ((SinglePhotoPage*) self);
		single_photo_page_cancel_zoom ((SinglePhotoPage*) self);
	}
	_tmp12_ = original;
	_tmp13_ = editing_host_page_get_photo (self);
	_tmp14_ = _tmp13_;
	photo_get_master_dimensions (_tmp14_, &_tmp15_);
	single_photo_page_set_pixbuf ((SinglePhotoPage*) self, _tmp12_, &_tmp15_, NULL);
	_g_object_unref0 (_tmp14_);
	_g_object_unref0 (original);
}

static void
editing_host_page_swap_out_original (EditingHostPage* self)
{
	GdkPixbuf* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->swapped;
	if (_tmp0_ != NULL) {
		GdkPixbuf* _tmp1_;
		Photo* _tmp2_;
		Photo* _tmp3_;
		Dimensions _tmp4_ = {0};
		_tmp1_ = self->priv->swapped;
		_tmp2_ = editing_host_page_get_photo (self);
		_tmp3_ = _tmp2_;
		media_source_get_dimensions ((MediaSource*) _tmp3_, PHOTO_EXCEPTION_NONE, &_tmp4_);
		single_photo_page_set_pixbuf ((SinglePhotoPage*) self, _tmp1_, &_tmp4_, NULL);
		_g_object_unref0 (_tmp3_);
		single_photo_page_restore_zoom_state ((SinglePhotoPage*) self);
		editing_host_page_update_cursor_for_zoom_context (self);
		_g_object_unref0 (self->priv->swapped);
		self->priv->swapped = NULL;
	}
}

static void
editing_host_page_activate_tool (EditingHostPage* self,
                                 EditingToolsEditingTool* tool)
{
	Dimensions _tmp0_ = {0};
	GdkPixbuf* _tmp1_;
	GdkPixbuf* unscaled = NULL;
	Dimensions max_dim = {0};
	Photo* _tmp2_;
	Photo* _tmp3_;
	Dimensions _tmp4_ = {0};
	Dimensions _tmp5_;
	GdkPixbuf* _tmp21_;
	EditingToolsPhotoCanvas* photo_canvas = NULL;
	EditingHostPageEditingHostCanvas* _tmp24_;
	EditingToolsEditingTool* _tmp25_;
	EditingToolsEditingTool* _tmp26_;
	EditingToolsPhotoCanvas* _tmp27_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tool != NULL);
	single_photo_page_save_zoom_state ((SinglePhotoPage*) self);
	single_photo_page_cancel_zoom ((SinglePhotoPage*) self);
	dimensions_init (&_tmp0_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp0_, FALSE);
	_tmp1_ = single_photo_page_get_unscaled_pixbuf ((SinglePhotoPage*) self);
	_g_object_unref0 (self->priv->cancel_editing_pixbuf);
	self->priv->cancel_editing_pixbuf = _tmp1_;
	_tmp2_ = editing_host_page_get_photo (self);
	_tmp3_ = _tmp2_;
	media_source_get_dimensions ((MediaSource*) _tmp3_, PHOTO_EXCEPTION_NONE, &_tmp4_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp3_);
	max_dim = _tmp5_;
	{
		Dimensions tool_pixbuf_dim = {0};
		Dimensions _tmp6_ = {0};
		GdkPixbuf* _tmp7_ = NULL;
		Scaling _tmp8_ = {0};
		Photo* _tmp9_;
		Photo* _tmp10_;
		Dimensions _tmp11_ = {0};
		GdkPixbuf* _tmp12_;
		GdkPixbuf* _tmp13_;
		GdkPixbuf* _tmp14_;
		GdkPixbuf* _tmp15_;
		_tmp6_.width = 0;
		tool_pixbuf_dim = _tmp6_;
		single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp8_);
		_tmp9_ = editing_host_page_get_photo (self);
		_tmp10_ = _tmp9_;
		_tmp12_ = editing_tools_editing_tool_get_display_pixbuf (tool, &_tmp8_, _tmp10_, &_tmp11_, &_inner_error0_);
		tool_pixbuf_dim = _tmp11_;
		_tmp13_ = _tmp12_;
		_g_object_unref0 (_tmp10_);
		_tmp7_ = _tmp13_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp14_ = _tmp7_;
		_tmp7_ = NULL;
		_g_object_unref0 (unscaled);
		unscaled = _tmp14_;
		_tmp15_ = unscaled;
		if (_tmp15_ != NULL) {
			Dimensions _tmp16_;
			_tmp16_ = tool_pixbuf_dim;
			max_dim = _tmp16_;
		}
		_g_object_unref0 (_tmp7_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp17_;
		const gchar* _tmp18_;
		GtkToggleButton* _tmp19_;
		GtkToggleButton* _tmp20_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp17_ = err;
		_tmp18_ = _tmp17_->message;
		g_warning ("EditingHostPage.vala:1125: %s", _tmp18_);
		editing_host_page_set_photo_missing (self, TRUE);
		_tmp19_ = self->priv->current_editing_toggle;
		_vala_assert (_tmp19_ != NULL, "current_editing_toggle != null");
		_tmp20_ = self->priv->current_editing_toggle;
		gtk_toggle_button_set_active (_tmp20_, FALSE);
		_g_error_free0 (err);
		_g_object_unref0 (unscaled);
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (unscaled);
		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;
	}
	_tmp21_ = unscaled;
	if (_tmp21_ != NULL) {
		GdkPixbuf* _tmp22_;
		Dimensions _tmp23_;
		_tmp22_ = unscaled;
		_tmp23_ = max_dim;
		single_photo_page_set_pixbuf ((SinglePhotoPage*) self, _tmp22_, &_tmp23_, NULL);
	}
	_tmp24_ = editing_host_page_editing_host_canvas_new (self);
	photo_canvas = (EditingToolsPhotoCanvas*) _tmp24_;
	_tmp25_ = _g_object_ref0 (tool);
	_g_object_unref0 (self->priv->current_tool);
	self->priv->current_tool = _tmp25_;
	_tmp26_ = self->priv->current_tool;
	_tmp27_ = photo_canvas;
	editing_tools_editing_tool_activate (_tmp26_, _tmp27_);
	editing_host_page_place_tool_window (self);
	single_photo_page_repaint ((SinglePhotoPage*) self, NULL);
	_g_object_unref0 (photo_canvas);
	_g_object_unref0 (unscaled);
}

static void
_editing_host_page_on_tool_activated_editing_tools_editing_tool_activated (EditingToolsEditingTool* _sender,
                                                                           gpointer self)
{
	editing_host_page_on_tool_activated ((EditingHostPage*) self);
}

static void
_editing_host_page_on_tool_deactivated_editing_tools_editing_tool_deactivated (EditingToolsEditingTool* _sender,
                                                                               gpointer self)
{
	editing_host_page_on_tool_deactivated ((EditingHostPage*) self);
}

static void
_editing_host_page_on_tool_applied_editing_tools_editing_tool_applied (EditingToolsEditingTool* _sender,
                                                                       Command* command,
                                                                       GdkPixbuf* new_pixbuf,
                                                                       Dimensions* new_max_dim,
                                                                       gboolean needs_improvement,
                                                                       gpointer self)
{
	editing_host_page_on_tool_applied ((EditingHostPage*) self, command, new_pixbuf, new_max_dim, needs_improvement);
}

static void
_editing_host_page_on_tool_cancelled_editing_tools_editing_tool_cancelled (EditingToolsEditingTool* _sender,
                                                                           gpointer self)
{
	editing_host_page_on_tool_cancelled ((EditingHostPage*) self);
}

static void
_editing_host_page_on_tool_aborted_editing_tools_editing_tool_aborted (EditingToolsEditingTool* _sender,
                                                                       gpointer self)
{
	editing_host_page_on_tool_aborted ((EditingHostPage*) self);
}

static gboolean
_editing_host_page_update_pixbuf_gsource_func (gpointer self)
{
	gboolean result;
	result = editing_host_page_update_pixbuf ((EditingHostPage*) self);
	return result;
}

static void
editing_host_page_deactivate_tool (EditingHostPage* self,
                                   Command* command,
                                   GdkPixbuf* new_pixbuf,
                                   Dimensions* new_max_dim,
                                   gboolean needs_improvement)
{
	EditingToolsEditingTool* _tmp0_;
	EditingToolsEditingTool* tool = NULL;
	EditingToolsEditingTool* _tmp1_;
	EditingToolsEditingTool* _tmp2_;
	EditingToolsEditingToolWindow* tool_window = NULL;
	EditingToolsEditingTool* _tmp3_;
	EditingToolsEditingToolWindow* _tmp4_;
	EditingToolsEditingToolWindow* _tmp5_;
	EditingToolsEditingTool* _tmp21_;
	EditingToolsEditingTool* _tmp22_;
	guint _tmp23_;
	EditingToolsEditingTool* _tmp24_;
	guint _tmp25_;
	EditingToolsEditingTool* _tmp26_;
	guint _tmp27_;
	EditingToolsEditingTool* _tmp28_;
	guint _tmp29_;
	EditingToolsEditingTool* _tmp30_;
	guint _tmp31_;
	GdkPixbuf* replacement = NULL;
	GdkPixbuf* _tmp38_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (new_max_dim != NULL);
	_tmp0_ = self->priv->current_tool;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->current_tool;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	tool = _tmp2_;
	_g_object_unref0 (self->priv->current_tool);
	self->priv->current_tool = NULL;
	_tmp3_ = tool;
	_tmp4_ = editing_tools_editing_tool_get_tool_window (_tmp3_);
	tool_window = _tmp4_;
	_tmp5_ = tool_window;
	if (_tmp5_ != NULL) {
		gint last_location_x = 0;
		gint last_location_y = 0;
		EditingToolsEditingToolWindow* _tmp6_;
		gint _tmp7_ = 0;
		gint _tmp8_ = 0;
		GeeHashMap* _tmp9_;
		EditingToolsEditingTool* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		GeeHashMap* _tmp15_;
		EditingToolsEditingTool* _tmp16_;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		_tmp6_ = tool_window;
		gtk_window_get_position ((GtkWindow*) _tmp6_, &_tmp7_, &_tmp8_);
		last_location_x = _tmp7_;
		last_location_y = _tmp8_;
		_tmp9_ = self->priv->last_locations;
		_tmp10_ = tool;
		_tmp11_ = editing_tools_editing_tool_get_name (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = g_strconcat (_tmp12_, "_x", NULL);
		_tmp14_ = _tmp13_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp9_, _tmp14_, (gpointer) ((gintptr) last_location_x));
		_g_free0 (_tmp14_);
		_tmp15_ = self->priv->last_locations;
		_tmp16_ = tool;
		_tmp17_ = editing_tools_editing_tool_get_name (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = g_strconcat (_tmp18_, "_y", NULL);
		_tmp20_ = _tmp19_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp15_, _tmp20_, (gpointer) ((gintptr) last_location_y));
		_g_free0 (_tmp20_);
	}
	_tmp21_ = tool;
	editing_tools_editing_tool_deactivate (_tmp21_);
	_tmp22_ = tool;
	g_signal_parse_name ("activated", EDITING_TOOLS_TYPE_EDITING_TOOL, &_tmp23_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp22_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp23_, 0, NULL, (GCallback) _editing_host_page_on_tool_activated_editing_tools_editing_tool_activated, self);
	_tmp24_ = tool;
	g_signal_parse_name ("deactivated", EDITING_TOOLS_TYPE_EDITING_TOOL, &_tmp25_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp24_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp25_, 0, NULL, (GCallback) _editing_host_page_on_tool_deactivated_editing_tools_editing_tool_deactivated, self);
	_tmp26_ = tool;
	g_signal_parse_name ("applied", EDITING_TOOLS_TYPE_EDITING_TOOL, &_tmp27_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp26_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp27_, 0, NULL, (GCallback) _editing_host_page_on_tool_applied_editing_tools_editing_tool_applied, self);
	_tmp28_ = tool;
	g_signal_parse_name ("cancelled", EDITING_TOOLS_TYPE_EDITING_TOOL, &_tmp29_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp28_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp29_, 0, NULL, (GCallback) _editing_host_page_on_tool_cancelled_editing_tools_editing_tool_cancelled, self);
	_tmp30_ = tool;
	g_signal_parse_name ("aborted", EDITING_TOOLS_TYPE_EDITING_TOOL, &_tmp31_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp30_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp31_, 0, NULL, (GCallback) _editing_host_page_on_tool_aborted_editing_tools_editing_tool_aborted, self);
	_g_object_unref0 (tool);
	tool = NULL;
	_g_object_unref0 (self->priv->current_editing_toggle);
	self->priv->current_editing_toggle = NULL;
	replacement = NULL;
	if (new_pixbuf != NULL) {
		GdkPixbuf* _tmp32_;
		_tmp32_ = _g_object_ref0 (new_pixbuf);
		_g_object_unref0 (replacement);
		replacement = _tmp32_;
	} else {
		GdkPixbuf* _tmp33_;
		_tmp33_ = self->priv->cancel_editing_pixbuf;
		if (_tmp33_ != NULL) {
			GdkPixbuf* _tmp34_;
			GdkPixbuf* _tmp35_;
			GdkPixbuf* _tmp36_;
			Dimensions _tmp37_ = {0};
			_tmp34_ = self->priv->cancel_editing_pixbuf;
			_tmp35_ = _g_object_ref0 (_tmp34_);
			_g_object_unref0 (replacement);
			replacement = _tmp35_;
			_tmp36_ = replacement;
			dimensions_for_pixbuf (_tmp36_, &_tmp37_);
			*new_max_dim = _tmp37_;
			needs_improvement = FALSE;
		} else {
			needs_improvement = TRUE;
		}
	}
	_tmp38_ = replacement;
	if (_tmp38_ != NULL) {
		GdkPixbuf* _tmp39_;
		Dimensions _tmp40_;
		_tmp39_ = replacement;
		_tmp40_ = *new_max_dim;
		single_photo_page_set_pixbuf ((SinglePhotoPage*) self, _tmp39_, &_tmp40_, NULL);
	}
	_g_object_unref0 (self->priv->cancel_editing_pixbuf);
	self->priv->cancel_editing_pixbuf = NULL;
	if (needs_improvement) {
		self->priv->pixbuf_dirty = TRUE;
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _editing_host_page_update_pixbuf_gsource_func, g_object_ref (self), g_object_unref);
	}
	if (command != NULL) {
		CommandManager* _tmp41_;
		CommandManager* _tmp42_;
		_tmp41_ = page_get_command_manager ((Page*) self);
		_tmp42_ = _tmp41_;
		command_manager_execute (_tmp42_, command);
		_command_manager_unref0 (_tmp42_);
	}
	_g_object_unref0 (replacement);
	_g_object_unref0 (tool_window);
	_g_object_unref0 (tool);
}

static gboolean
editing_host_page_real_on_double_click (EditingHostPage* self,
                                        GdkEventButton* event)
{
	gboolean result;
	g_return_val_if_fail (event != NULL, FALSE);
	result = FALSE;
	return result;
}

gboolean
editing_host_page_on_double_click (EditingHostPage* self,
                                   GdkEventButton* event)
{
	EditingHostPageClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->on_double_click) {
		return _klass_->on_double_click (self, event);
	}
	return FALSE;
}

static gboolean
editing_host_page_real_on_left_click (Page* base,
                                      GdkEventButton* event)
{
	EditingHostPage * self;
	gint x = 0;
	gint y = 0;
	gboolean _tmp2_ = FALSE;
	EditingToolsEditingTool* _tmp3_;
	EditingToolsEditingTool* _tmp7_;
	EditingToolsEditingTool* _tmp8_;
	gboolean result;
	self = (EditingHostPage*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	if (event->type == GDK_2BUTTON_PRESS) {
		gboolean _tmp0_ = FALSE;
		EditingToolsEditingTool* _tmp1_;
		_tmp1_ = self->priv->current_tool;
		if (_tmp1_ == NULL) {
			_tmp0_ = editing_host_page_on_double_click (self, event);
		} else {
			_tmp0_ = FALSE;
		}
		result = _tmp0_;
		return result;
	}
	x = (gint) event->x;
	y = (gint) event->y;
	_tmp3_ = self->priv->current_tool;
	if (_tmp3_ == NULL) {
		SliderAssembly* _tmp4_;
		gdouble _tmp5_;
		gdouble _tmp6_;
		_tmp4_ = self->priv->zoom_assembly;
		_tmp5_ = slider_assembly_get_slider_value (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp2_ = _tmp6_ != 0.0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		self->priv->zoom_pan_start_point.x = (gint) event->x;
		self->priv->zoom_pan_start_point.y = (gint) event->y;
		self->priv->is_pan_in_progress = TRUE;
		page_suspend_cursor_hiding ((Page*) self);
		result = TRUE;
		return result;
	}
	_tmp7_ = self->priv->current_tool;
	if (_tmp7_ == NULL) {
		result = FALSE;
		return result;
	}
	if (!single_photo_page_is_inside_pixbuf ((SinglePhotoPage*) self, x, y)) {
		result = TRUE;
		return result;
	}
	_tmp8_ = self->priv->current_tool;
	editing_tools_editing_tool_on_left_click (_tmp8_, x, y);
	result = TRUE;
	return result;
}

static gboolean
editing_host_page_real_on_left_released (Page* base,
                                         GdkEventButton* event)
{
	EditingHostPage * self;
	EditingToolsEditingTool* _tmp10_;
	EditingToolsEditingTool* _tmp11_;
	EditingToolsEditingTool* _tmp12_;
	EditingToolsEditingToolWindow* _tmp13_;
	EditingToolsEditingToolWindow* _tmp14_;
	gboolean _tmp15_;
	gboolean result;
	self = (EditingHostPage*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	if (self->priv->is_pan_in_progress) {
		GdkPoint viewport_center = {0};
		ZoomState _tmp0_ = {0};
		GdkPoint _tmp1_ = {0};
		gint delta_x = 0;
		GdkPoint _tmp2_;
		gint delta_y = 0;
		GdkPoint _tmp3_;
		ZoomState zoom_state = {0};
		ZoomState _tmp4_ = {0};
		GdkPoint _tmp5_;
		ZoomState _tmp6_;
		ZoomBuffer* _tmp7_;
		ZoomBuffer* _tmp8_;
		ZoomState _tmp9_;
		single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp0_);
		zoom_state_get_viewport_center (&_tmp0_, &_tmp1_);
		viewport_center = _tmp1_;
		_tmp2_ = self->priv->zoom_pan_start_point;
		delta_x = ((gint) event->x) - _tmp2_.x;
		_tmp3_ = self->priv->zoom_pan_start_point;
		delta_y = ((gint) event->y) - _tmp3_.y;
		viewport_center.x = viewport_center.x - delta_x;
		viewport_center.y = viewport_center.y - delta_y;
		single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp4_);
		_tmp5_ = viewport_center;
		zoom_state_init_pan (&zoom_state, &_tmp4_, &_tmp5_);
		_tmp6_ = zoom_state;
		single_photo_page_set_zoom_state ((SinglePhotoPage*) self, &_tmp6_);
		_tmp7_ = single_photo_page_get_zoom_buffer ((SinglePhotoPage*) self);
		_tmp8_ = _tmp7_;
		_tmp9_ = zoom_state;
		zoom_buffer_flush_demand_cache (_tmp8_, &_tmp9_);
		_g_object_unref0 (_tmp8_);
		self->priv->is_pan_in_progress = FALSE;
		page_restore_cursor_hiding ((Page*) self);
	}
	_tmp10_ = self->priv->current_tool;
	if (_tmp10_ == NULL) {
		result = FALSE;
		return result;
	}
	_tmp11_ = self->priv->current_tool;
	editing_tools_editing_tool_on_left_released (_tmp11_, (gint) event->x, (gint) event->y);
	_tmp12_ = self->priv->current_tool;
	_tmp13_ = editing_tools_editing_tool_get_tool_window (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = _tmp14_ != NULL;
	_g_object_unref0 (_tmp14_);
	if (_tmp15_) {
		EditingToolsEditingTool* _tmp16_;
		EditingToolsEditingToolWindow* _tmp17_;
		EditingToolsEditingToolWindow* _tmp18_;
		_tmp16_ = self->priv->current_tool;
		_tmp17_ = editing_tools_editing_tool_get_tool_window (_tmp16_);
		_tmp18_ = _tmp17_;
		gtk_window_present ((GtkWindow*) _tmp18_);
		_g_object_unref0 (_tmp18_);
	}
	result = FALSE;
	return result;
}

static gboolean
editing_host_page_real_on_right_click (Page* base,
                                       GdkEventButton* event)
{
	EditingHostPage * self;
	gboolean result;
	self = (EditingHostPage*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	result = page_on_context_buttonpress ((Page*) self, event);
	return result;
}

static gboolean
_editing_host_page_on_fetch_original_gsource_func (gpointer self)
{
	gboolean result;
	result = editing_host_page_on_fetch_original ((EditingHostPage*) self);
	return result;
}

static void
editing_host_page_on_photos_altered (EditingHostPage* self,
                                     GeeMap* map)
{
	Photo* _tmp0_;
	Photo* _tmp1_;
	gboolean _tmp2_;
	Photo* _tmp3_;
	Photo* _tmp4_;
	gboolean _tmp5_;
	ViewCollection* _tmp6_;
	ViewCollection* _tmp7_;
	ViewCollection* _tmp8_;
	ViewCollection* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (map != NULL);
	_tmp0_ = editing_host_page_get_photo (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = !gee_map_has_key (map, (DataObject*) _tmp1_);
	_g_object_unref0 (_tmp1_);
	if (_tmp2_) {
		return;
	}
	self->priv->pixbuf_dirty = TRUE;
	_tmp3_ = editing_host_page_get_photo (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = photo_has_transformations (_tmp4_);
	_g_object_unref0 (_tmp4_);
	if (_tmp5_) {
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _editing_host_page_on_fetch_original_gsource_func, g_object_ref (self), g_object_unref);
	}
	_tmp6_ = page_get_view ((Page*) self);
	_tmp7_ = _tmp6_;
	_tmp8_ = page_get_view ((Page*) self);
	_tmp9_ = _tmp8_;
	page_update_actions ((Page*) self, view_collection_get_selected_count (_tmp7_), data_collection_get_count ((DataCollection*) _tmp9_));
	_data_collection_unref0 (_tmp9_);
	_data_collection_unref0 (_tmp7_);
}

static void
editing_host_page_on_view_contents_ordering_altered (EditingHostPage* self)
{
	g_return_if_fail (self != NULL);
	editing_host_page_refresh_caches (self, "on_view_contents_ordering_altered");
}

static gboolean
editing_host_page_on_fetch_original (EditingHostPage* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (editing_host_page_has_photo (self)) {
		PixbufCache* _tmp0_;
		Photo* _tmp1_;
		Photo* _tmp2_;
		_tmp0_ = self->priv->master_cache;
		_tmp1_ = editing_host_page_get_photo (self);
		_tmp2_ = _tmp1_;
		pixbuf_cache_prefetch (_tmp0_, _tmp2_, BACKGROUND_JOB_JOB_PRIORITY_LOW, FALSE);
		_g_object_unref0 (_tmp2_);
	}
	result = FALSE;
	return result;
}

static gboolean
editing_host_page_is_panning_possible (EditingHostPage* self)
{
	Dimensions content_dim = {0};
	Dimensions _tmp0_ = {0};
	ZoomState _tmp1_ = {0};
	ZoomState _tmp2_ = {0};
	Dimensions canvas_dim = {0};
	Dimensions _tmp3_ = {0};
	gboolean _tmp4_ = FALSE;
	Dimensions _tmp5_;
	Dimensions _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_.width = 0;
	content_dim = _tmp0_;
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp1_);
	content_dim.width = zoom_state_get_zoomed_width (&_tmp1_);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp2_);
	content_dim.height = zoom_state_get_zoomed_height (&_tmp2_);
	single_photo_page_get_surface_dim ((SinglePhotoPage*) self, &_tmp3_);
	canvas_dim = _tmp3_;
	_tmp5_ = canvas_dim;
	_tmp6_ = content_dim;
	if (_tmp5_.width >= _tmp6_.width) {
		Dimensions _tmp7_;
		Dimensions _tmp8_;
		_tmp7_ = canvas_dim;
		_tmp8_ = content_dim;
		_tmp4_ = _tmp7_.height >= _tmp8_.height;
	} else {
		_tmp4_ = FALSE;
	}
	result = !_tmp4_;
	return result;
}

static void
editing_host_page_update_cursor_for_zoom_context (EditingHostPage* self)
{
	g_return_if_fail (self != NULL);
	if (editing_host_page_is_panning_possible (self)) {
		page_set_page_cursor ((Page*) self, GDK_FLEUR);
	} else {
		page_set_page_cursor ((Page*) self, GDK_LEFT_PTR);
	}
}

static gboolean
editing_host_page_real_on_motion (Page* base,
                                  GdkEventMotion* event,
                                  gint x,
                                  gint y,
                                  GdkModifierType mask)
{
	EditingHostPage * self;
	EditingToolsEditingTool* _tmp0_;
	gboolean result;
	self = (EditingHostPage*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->current_tool;
	if (_tmp0_ != NULL) {
		EditingToolsEditingTool* _tmp1_;
		_tmp1_ = self->priv->current_tool;
		editing_tools_editing_tool_on_motion (_tmp1_, x, y, mask);
		gdk_event_request_motions (event);
		result = TRUE;
		return result;
	}
	editing_host_page_update_cursor_for_zoom_context (self);
	if (self->priv->is_pan_in_progress) {
		gint delta_x = 0;
		GdkPoint _tmp2_;
		gint delta_y = 0;
		GdkPoint _tmp3_;
		GdkPoint viewport_center = {0};
		ZoomState _tmp4_ = {0};
		GdkPoint _tmp5_ = {0};
		ZoomState zoom_state = {0};
		ZoomState _tmp6_ = {0};
		GdkPoint _tmp7_;
		ZoomState _tmp8_;
		_tmp2_ = self->priv->zoom_pan_start_point;
		delta_x = ((gint) event->x) - _tmp2_.x;
		_tmp3_ = self->priv->zoom_pan_start_point;
		delta_y = ((gint) event->y) - _tmp3_.y;
		single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp4_);
		zoom_state_get_viewport_center (&_tmp4_, &_tmp5_);
		viewport_center = _tmp5_;
		viewport_center.x = viewport_center.x - delta_x;
		viewport_center.y = viewport_center.y - delta_y;
		single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp6_);
		_tmp7_ = viewport_center;
		zoom_state_init_pan (&zoom_state, &_tmp6_, &_tmp7_);
		_tmp8_ = zoom_state;
		single_photo_page_on_interactive_pan ((SinglePhotoPage*) self, &_tmp8_);
		result = TRUE;
		return result;
	}
	result = PAGE_CLASS (editing_host_page_parent_class)->on_motion ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), event, x, y, mask);
	return result;
}

static gboolean
editing_host_page_real_on_leave_notify_event (Page* base)
{
	EditingHostPage * self;
	EditingToolsEditingTool* _tmp0_;
	gboolean result;
	self = (EditingHostPage*) base;
	_tmp0_ = self->priv->current_tool;
	if (_tmp0_ != NULL) {
		EditingToolsEditingTool* _tmp1_;
		_tmp1_ = self->priv->current_tool;
		result = editing_tools_editing_tool_on_leave_notify_event (_tmp1_);
		return result;
	}
	result = PAGE_CLASS (editing_host_page_parent_class)->on_leave_notify_event ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage));
	return result;
}

static void
editing_host_page_real_on_move_finished (Page* base,
                                         GdkRectangle* rect)
{
	EditingHostPage * self;
	GeeHashMap* _tmp0_;
	GdkRectangle _tmp1_;
	self = (EditingHostPage*) base;
	g_return_if_fail (rect != NULL);
	_tmp0_ = self->priv->last_locations;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp0_);
	_tmp1_ = *rect;
	PAGE_CLASS (editing_host_page_parent_class)->on_move_finished ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), &_tmp1_);
}

static gboolean
editing_host_page_on_keyboard_pan_event (EditingHostPage* self,
                                         GdkEventKey* event)
{
	ZoomState current_zoom_state = {0};
	ZoomState _tmp0_ = {0};
	GdkPoint viewport_center = {0};
	GdkPoint _tmp1_ = {0};
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GQuark _tmp5_ = 0U;
	static GQuark _tmp4_label0 = 0;
	static GQuark _tmp4_label1 = 0;
	static GQuark _tmp4_label2 = 0;
	static GQuark _tmp4_label3 = 0;
	static GQuark _tmp4_label4 = 0;
	static GQuark _tmp4_label5 = 0;
	static GQuark _tmp4_label6 = 0;
	static GQuark _tmp4_label7 = 0;
	static GQuark _tmp4_label8 = 0;
	static GQuark _tmp4_label9 = 0;
	static GQuark _tmp4_label10 = 0;
	static GQuark _tmp4_label11 = 0;
	ZoomState new_zoom_state = {0};
	ZoomState _tmp6_;
	GdkPoint _tmp7_;
	ZoomState _tmp8_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp0_);
	current_zoom_state = _tmp0_;
	zoom_state_get_viewport_center (&current_zoom_state, &_tmp1_);
	viewport_center = _tmp1_;
	_tmp2_ = gdk_keyval_name (event->keyval);
	_tmp3_ = _tmp2_;
	_tmp5_ = (NULL == _tmp3_) ? 0 : g_quark_from_string (_tmp3_);
	if (((_tmp5_ == ((0 != _tmp4_label0) ? _tmp4_label0 : (_tmp4_label0 = g_quark_from_static_string ("Left")))) || (_tmp5_ == ((0 != _tmp4_label1) ? _tmp4_label1 : (_tmp4_label1 = g_quark_from_static_string ("KP_Left"))))) || (_tmp5_ == ((0 != _tmp4_label2) ? _tmp4_label2 : (_tmp4_label2 = g_quark_from_static_string ("KP_4"))))) {
		switch (0) {
			default:
			{
				viewport_center.x = viewport_center.x - EDITING_HOST_PAGE_PAN_INCREMENT_SIZE;
				break;
			}
		}
	} else if (((_tmp5_ == ((0 != _tmp4_label3) ? _tmp4_label3 : (_tmp4_label3 = g_quark_from_static_string ("Right")))) || (_tmp5_ == ((0 != _tmp4_label4) ? _tmp4_label4 : (_tmp4_label4 = g_quark_from_static_string ("KP_Right"))))) || (_tmp5_ == ((0 != _tmp4_label5) ? _tmp4_label5 : (_tmp4_label5 = g_quark_from_static_string ("KP_6"))))) {
		switch (0) {
			default:
			{
				viewport_center.x = viewport_center.x + EDITING_HOST_PAGE_PAN_INCREMENT_SIZE;
				break;
			}
		}
	} else if (((_tmp5_ == ((0 != _tmp4_label6) ? _tmp4_label6 : (_tmp4_label6 = g_quark_from_static_string ("Down")))) || (_tmp5_ == ((0 != _tmp4_label7) ? _tmp4_label7 : (_tmp4_label7 = g_quark_from_static_string ("KP_Down"))))) || (_tmp5_ == ((0 != _tmp4_label8) ? _tmp4_label8 : (_tmp4_label8 = g_quark_from_static_string ("KP_2"))))) {
		switch (0) {
			default:
			{
				viewport_center.y = viewport_center.y + EDITING_HOST_PAGE_PAN_INCREMENT_SIZE;
				break;
			}
		}
	} else if (((_tmp5_ == ((0 != _tmp4_label9) ? _tmp4_label9 : (_tmp4_label9 = g_quark_from_static_string ("Up")))) || (_tmp5_ == ((0 != _tmp4_label10) ? _tmp4_label10 : (_tmp4_label10 = g_quark_from_static_string ("KP_Up"))))) || (_tmp5_ == ((0 != _tmp4_label11) ? _tmp4_label11 : (_tmp4_label11 = g_quark_from_static_string ("KP_8"))))) {
		switch (0) {
			default:
			{
				viewport_center.y = viewport_center.y - EDITING_HOST_PAGE_PAN_INCREMENT_SIZE;
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	}
	_tmp6_ = current_zoom_state;
	_tmp7_ = viewport_center;
	zoom_state_init_pan (&new_zoom_state, &_tmp6_, &_tmp7_);
	_tmp8_ = new_zoom_state;
	single_photo_page_set_zoom_state ((SinglePhotoPage*) self, &_tmp8_);
	single_photo_page_repaint ((SinglePhotoPage*) self, NULL);
	result = TRUE;
	return result;
}

static gboolean
editing_host_page_real_key_press_event (GtkWidget* base,
                                        GdkEventKey* event)
{
	EditingHostPage * self;
	EditingToolsEditingTool* _tmp0_;
	gboolean handled = FALSE;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GQuark _tmp5_ = 0U;
	static GQuark _tmp4_label0 = 0;
	static GQuark _tmp4_label1 = 0;
	static GQuark _tmp4_label2 = 0;
	static GQuark _tmp4_label3 = 0;
	static GQuark _tmp4_label4 = 0;
	static GQuark _tmp4_label5 = 0;
	static GQuark _tmp4_label6 = 0;
	static GQuark _tmp4_label7 = 0;
	gboolean _tmp6_ = FALSE;
	gboolean result;
	self = (EditingHostPage*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->current_tool;
	if (_tmp0_ != NULL) {
		EditingToolsEditingTool* _tmp1_;
		_tmp1_ = self->priv->current_tool;
		if (editing_tools_editing_tool_on_keypress (_tmp1_, event)) {
			result = TRUE;
			return result;
		}
	}
	if (editing_host_page_is_panning_possible (self)) {
		if (editing_host_page_on_keyboard_pan_event (self, event)) {
			result = TRUE;
			return result;
		}
	}
	if (editing_host_page_on_zoom_assembly_key_press (self, event)) {
		result = TRUE;
		return result;
	}
	handled = TRUE;
	_tmp2_ = gdk_keyval_name (event->keyval);
	_tmp3_ = _tmp2_;
	_tmp5_ = (NULL == _tmp3_) ? 0 : g_quark_from_string (_tmp3_);
	if ((_tmp5_ == ((0 != _tmp4_label0) ? _tmp4_label0 : (_tmp4_label0 = g_quark_from_static_string ("Down")))) || (_tmp5_ == ((0 != _tmp4_label1) ? _tmp4_label1 : (_tmp4_label1 = g_quark_from_static_string ("KP_Down"))))) {
		switch (0) {
			default:
			{
				break;
			}
		}
	} else if (((_tmp5_ == ((0 != _tmp4_label2) ? _tmp4_label2 : (_tmp4_label2 = g_quark_from_static_string ("equal")))) || (_tmp5_ == ((0 != _tmp4_label3) ? _tmp4_label3 : (_tmp4_label3 = g_quark_from_static_string ("plus"))))) || (_tmp5_ == ((0 != _tmp4_label4) ? _tmp4_label4 : (_tmp4_label4 = g_quark_from_static_string ("KP_Add"))))) {
		switch (0) {
			default:
			{
				page_activate_action ((Page*) self, "IncreaseSize");
				break;
			}
		}
	} else if (((_tmp5_ == ((0 != _tmp4_label5) ? _tmp4_label5 : (_tmp4_label5 = g_quark_from_static_string ("minus")))) || (_tmp5_ == ((0 != _tmp4_label6) ? _tmp4_label6 : (_tmp4_label6 = g_quark_from_static_string ("underscore"))))) || (_tmp5_ == ((0 != _tmp4_label7) ? _tmp4_label7 : (_tmp4_label7 = g_quark_from_static_string ("KP_Subtract"))))) {
		switch (0) {
			default:
			{
				page_activate_action ((Page*) self, "DecreaseSize");
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				handled = FALSE;
				break;
			}
		}
	}
	if (handled) {
		result = TRUE;
		return result;
	}
	if (GTK_WIDGET_CLASS (editing_host_page_parent_class)->key_press_event != NULL) {
		_tmp6_ = GTK_WIDGET_CLASS (editing_host_page_parent_class)->key_press_event ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), event);
	} else {
		_tmp6_ = TRUE;
	}
	result = _tmp6_;
	return result;
}

static void
editing_host_page_real_new_surface (SinglePhotoPage* base,
                                    cairo_t* default_ctx,
                                    Dimensions* dim)
{
	EditingHostPage * self;
	EditingToolsEditingTool* _tmp0_;
	self = (EditingHostPage*) base;
	g_return_if_fail (default_ctx != NULL);
	g_return_if_fail (dim != NULL);
	_tmp0_ = self->priv->current_tool;
	if (_tmp0_ != NULL) {
		EditingToolsEditingTool* _tmp1_;
		EditingToolsPhotoCanvas* _tmp2_;
		Dimensions _tmp3_;
		_tmp1_ = self->priv->current_tool;
		_tmp2_ = _tmp1_->canvas;
		_tmp3_ = *dim;
		editing_tools_photo_canvas_set_surface (_tmp2_, default_ctx, &_tmp3_);
	}
}

static void
editing_host_page_real_updated_pixbuf (SinglePhotoPage* base,
                                       GdkPixbuf* pixbuf,
                                       SinglePhotoPageUpdateReason reason,
                                       Dimensions* old_dim)
{
	EditingHostPage * self;
	gboolean _tmp0_ = FALSE;
	EditingToolsEditingTool* _tmp1_;
	self = (EditingHostPage*) base;
	g_return_if_fail (pixbuf != NULL);
	g_return_if_fail (old_dim != NULL);
	_tmp1_ = self->priv->current_tool;
	if (_tmp1_ != NULL) {
		_tmp0_ = reason != SINGLE_PHOTO_PAGE_UPDATE_REASON_QUALITY_IMPROVEMENT;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		EditingToolsEditingTool* _tmp2_;
		EditingToolsPhotoCanvas* _tmp3_;
		Dimensions _tmp4_;
		GdkRectangle _tmp5_ = {0};
		_tmp2_ = self->priv->current_tool;
		_tmp3_ = _tmp2_->canvas;
		_tmp4_ = *old_dim;
		single_photo_page_get_scaled_pixbuf_position ((SinglePhotoPage*) self, &_tmp5_);
		editing_tools_photo_canvas_resized_pixbuf (_tmp3_, &_tmp4_, pixbuf, &_tmp5_);
		_g_object_unref0 (self->priv->cancel_editing_pixbuf);
		self->priv->cancel_editing_pixbuf = NULL;
	}
}

static GdkPixbuf*
editing_host_page_real_get_bottom_left_trinket (EditingHostPage* self,
                                                gint scale)
{
	GdkPixbuf* result;
	result = NULL;
	return result;
}

GdkPixbuf*
editing_host_page_get_bottom_left_trinket (EditingHostPage* self,
                                           gint scale)
{
	EditingHostPageClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->get_bottom_left_trinket) {
		return _klass_->get_bottom_left_trinket (self, scale);
	}
	return NULL;
}

static GdkPixbuf*
editing_host_page_real_get_top_left_trinket (EditingHostPage* self,
                                             gint scale)
{
	GdkPixbuf* result;
	result = NULL;
	return result;
}

GdkPixbuf*
editing_host_page_get_top_left_trinket (EditingHostPage* self,
                                        gint scale)
{
	EditingHostPageClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->get_top_left_trinket) {
		return _klass_->get_top_left_trinket (self, scale);
	}
	return NULL;
}

static GdkPixbuf*
editing_host_page_real_get_top_right_trinket (EditingHostPage* self,
                                              gint scale)
{
	GdkPixbuf* result;
	result = NULL;
	return result;
}

GdkPixbuf*
editing_host_page_get_top_right_trinket (EditingHostPage* self,
                                         gint scale)
{
	EditingHostPageClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->get_top_right_trinket) {
		return _klass_->get_top_right_trinket (self, scale);
	}
	return NULL;
}

static GdkPixbuf*
editing_host_page_real_get_bottom_right_trinket (EditingHostPage* self,
                                                 gint scale)
{
	GdkPixbuf* result;
	result = NULL;
	return result;
}

GdkPixbuf*
editing_host_page_get_bottom_right_trinket (EditingHostPage* self,
                                            gint scale)
{
	EditingHostPageClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = EDITING_HOST_PAGE_GET_CLASS (self);
	if (_klass_->get_bottom_right_trinket) {
		return _klass_->get_bottom_right_trinket (self, scale);
	}
	return NULL;
}

static void
editing_host_page_real_paint (SinglePhotoPage* base,
                              cairo_t* ctx,
                              Dimensions* ctx_dim)
{
	EditingHostPage * self;
	EditingToolsEditingTool* _tmp0_;
	gboolean _tmp2_ = FALSE;
	Dimensions _tmp15_;
	ZoomState _tmp16_ = {0};
	GdkRectangle scaled_rect = {0};
	GdkRectangle _tmp17_ = {0};
	GdkPixbuf* trinket = NULL;
	GdkPixbuf* _tmp18_;
	GdkPixbuf* _tmp19_;
	GdkPixbuf* _tmp33_;
	GdkPixbuf* _tmp34_;
	GdkPixbuf* _tmp44_;
	GdkPixbuf* _tmp45_;
	GdkPixbuf* _tmp59_;
	GdkPixbuf* _tmp60_;
	self = (EditingHostPage*) base;
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (ctx_dim != NULL);
	_tmp0_ = self->priv->current_tool;
	if (_tmp0_ != NULL) {
		EditingToolsEditingTool* _tmp1_;
		_tmp1_ = self->priv->current_tool;
		editing_tools_editing_tool_paint (_tmp1_, ctx);
		return;
	}
	if (self->priv->photo_missing) {
		_tmp2_ = editing_host_page_has_photo (self);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		GtkDrawingArea* _tmp3_;
		GtkStyleContext* _tmp4_;
		Dimensions _tmp5_;
		Dimensions _tmp6_;
		Photo* _tmp7_;
		Photo* _tmp8_;
		GFile* _tmp9_;
		GFile* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		_tmp3_ = ((SinglePhotoPage*) self)->canvas;
		_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) _tmp3_);
		_tmp5_ = *ctx_dim;
		_tmp6_ = *ctx_dim;
		gtk_render_background (_tmp4_, ctx, (gdouble) 0, (gdouble) 0, (gdouble) _tmp5_.width, (gdouble) _tmp6_.height);
		cairo_paint (ctx);
		_tmp7_ = editing_host_page_get_photo (self);
		_tmp8_ = _tmp7_;
		_tmp9_ = media_source_get_file ((MediaSource*) _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = g_file_get_path (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = g_strdup_printf (_ ("Photo source file missing: %s"), _tmp12_);
		_tmp14_ = _tmp13_;
		editing_host_page_draw_message (self, _tmp14_);
		_g_free0 (_tmp14_);
		_g_free0 (_tmp12_);
		_g_object_unref0 (_tmp10_);
		_g_object_unref0 (_tmp8_);
		return;
	}
	_tmp15_ = *ctx_dim;
	SINGLE_PHOTO_PAGE_CLASS (editing_host_page_parent_class)->paint (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), ctx, &_tmp15_);
	single_photo_page_get_zoom_state ((SinglePhotoPage*) self, &_tmp16_);
	if (!zoom_state_is_default (&_tmp16_)) {
		return;
	}
	single_photo_page_get_scaled_pixbuf_position ((SinglePhotoPage*) self, &_tmp17_);
	scaled_rect = _tmp17_;
	_tmp18_ = editing_host_page_get_bottom_left_trinket (self, EDITING_HOST_PAGE_TRINKET_SCALE);
	trinket = _tmp18_;
	_tmp19_ = trinket;
	if (_tmp19_ != NULL) {
		gint x = 0;
		GdkRectangle _tmp20_;
		gint y = 0;
		GdkRectangle _tmp21_;
		GdkRectangle _tmp22_;
		GdkPixbuf* _tmp23_;
		gint _tmp24_;
		gint _tmp25_;
		GdkPixbuf* _tmp26_;
		GdkPixbuf* _tmp27_;
		gint _tmp28_;
		gint _tmp29_;
		GdkPixbuf* _tmp30_;
		gint _tmp31_;
		gint _tmp32_;
		_tmp20_ = scaled_rect;
		x = _tmp20_.x + EDITING_HOST_PAGE_TRINKET_PADDING;
		_tmp21_ = scaled_rect;
		_tmp22_ = scaled_rect;
		_tmp23_ = trinket;
		_tmp24_ = gdk_pixbuf_get_height (_tmp23_);
		_tmp25_ = _tmp24_;
		y = ((_tmp21_.y + _tmp22_.height) - _tmp25_) - EDITING_HOST_PAGE_TRINKET_PADDING;
		_tmp26_ = trinket;
		gdk_cairo_set_source_pixbuf (ctx, _tmp26_, (gdouble) x, (gdouble) y);
		_tmp27_ = trinket;
		_tmp28_ = gdk_pixbuf_get_width (_tmp27_);
		_tmp29_ = _tmp28_;
		_tmp30_ = trinket;
		_tmp31_ = gdk_pixbuf_get_height (_tmp30_);
		_tmp32_ = _tmp31_;
		cairo_rectangle (ctx, (gdouble) x, (gdouble) y, (gdouble) _tmp29_, (gdouble) _tmp32_);
		cairo_fill (ctx);
	}
	_tmp33_ = editing_host_page_get_top_left_trinket (self, EDITING_HOST_PAGE_TRINKET_SCALE);
	_g_object_unref0 (trinket);
	trinket = _tmp33_;
	_tmp34_ = trinket;
	if (_tmp34_ != NULL) {
		gint x = 0;
		GdkRectangle _tmp35_;
		gint y = 0;
		GdkRectangle _tmp36_;
		GdkPixbuf* _tmp37_;
		GdkPixbuf* _tmp38_;
		gint _tmp39_;
		gint _tmp40_;
		GdkPixbuf* _tmp41_;
		gint _tmp42_;
		gint _tmp43_;
		_tmp35_ = scaled_rect;
		x = _tmp35_.x + EDITING_HOST_PAGE_TRINKET_PADDING;
		_tmp36_ = scaled_rect;
		y = _tmp36_.y + EDITING_HOST_PAGE_TRINKET_PADDING;
		_tmp37_ = trinket;
		gdk_cairo_set_source_pixbuf (ctx, _tmp37_, (gdouble) x, (gdouble) y);
		_tmp38_ = trinket;
		_tmp39_ = gdk_pixbuf_get_width (_tmp38_);
		_tmp40_ = _tmp39_;
		_tmp41_ = trinket;
		_tmp42_ = gdk_pixbuf_get_height (_tmp41_);
		_tmp43_ = _tmp42_;
		cairo_rectangle (ctx, (gdouble) x, (gdouble) y, (gdouble) _tmp40_, (gdouble) _tmp43_);
		cairo_fill (ctx);
	}
	_tmp44_ = editing_host_page_get_top_right_trinket (self, EDITING_HOST_PAGE_TRINKET_SCALE);
	_g_object_unref0 (trinket);
	trinket = _tmp44_;
	_tmp45_ = trinket;
	if (_tmp45_ != NULL) {
		gint x = 0;
		GdkRectangle _tmp46_;
		GdkRectangle _tmp47_;
		GdkPixbuf* _tmp48_;
		gint _tmp49_;
		gint _tmp50_;
		gint y = 0;
		GdkRectangle _tmp51_;
		GdkPixbuf* _tmp52_;
		GdkPixbuf* _tmp53_;
		gint _tmp54_;
		gint _tmp55_;
		GdkPixbuf* _tmp56_;
		gint _tmp57_;
		gint _tmp58_;
		_tmp46_ = scaled_rect;
		_tmp47_ = scaled_rect;
		_tmp48_ = trinket;
		_tmp49_ = gdk_pixbuf_get_width (_tmp48_);
		_tmp50_ = _tmp49_;
		x = ((_tmp46_.x + _tmp47_.width) - _tmp50_) - EDITING_HOST_PAGE_TRINKET_PADDING;
		_tmp51_ = scaled_rect;
		y = _tmp51_.y + EDITING_HOST_PAGE_TRINKET_PADDING;
		_tmp52_ = trinket;
		gdk_cairo_set_source_pixbuf (ctx, _tmp52_, (gdouble) x, (gdouble) y);
		_tmp53_ = trinket;
		_tmp54_ = gdk_pixbuf_get_width (_tmp53_);
		_tmp55_ = _tmp54_;
		_tmp56_ = trinket;
		_tmp57_ = gdk_pixbuf_get_height (_tmp56_);
		_tmp58_ = _tmp57_;
		cairo_rectangle (ctx, (gdouble) x, (gdouble) y, (gdouble) _tmp55_, (gdouble) _tmp58_);
		cairo_fill (ctx);
	}
	_tmp59_ = editing_host_page_get_bottom_right_trinket (self, EDITING_HOST_PAGE_TRINKET_SCALE);
	_g_object_unref0 (trinket);
	trinket = _tmp59_;
	_tmp60_ = trinket;
	if (_tmp60_ != NULL) {
		gint x = 0;
		GdkRectangle _tmp61_;
		GdkRectangle _tmp62_;
		GdkPixbuf* _tmp63_;
		gint _tmp64_;
		gint _tmp65_;
		gint y = 0;
		GdkRectangle _tmp66_;
		GdkRectangle _tmp67_;
		GdkPixbuf* _tmp68_;
		gint _tmp69_;
		gint _tmp70_;
		GdkPixbuf* _tmp71_;
		GdkPixbuf* _tmp72_;
		gint _tmp73_;
		gint _tmp74_;
		GdkPixbuf* _tmp75_;
		gint _tmp76_;
		gint _tmp77_;
		_tmp61_ = scaled_rect;
		_tmp62_ = scaled_rect;
		_tmp63_ = trinket;
		_tmp64_ = gdk_pixbuf_get_width (_tmp63_);
		_tmp65_ = _tmp64_;
		x = ((_tmp61_.x + _tmp62_.width) - _tmp65_) - EDITING_HOST_PAGE_TRINKET_PADDING;
		_tmp66_ = scaled_rect;
		_tmp67_ = scaled_rect;
		_tmp68_ = trinket;
		_tmp69_ = gdk_pixbuf_get_height (_tmp68_);
		_tmp70_ = _tmp69_;
		y = ((_tmp66_.y + _tmp67_.height) - _tmp70_) - EDITING_HOST_PAGE_TRINKET_PADDING;
		_tmp71_ = trinket;
		gdk_cairo_set_source_pixbuf (ctx, _tmp71_, (gdouble) x, (gdouble) y);
		_tmp72_ = trinket;
		_tmp73_ = gdk_pixbuf_get_width (_tmp72_);
		_tmp74_ = _tmp73_;
		_tmp75_ = trinket;
		_tmp76_ = gdk_pixbuf_get_height (_tmp75_);
		_tmp77_ = _tmp76_;
		cairo_rectangle (ctx, (gdouble) x, (gdouble) y, (gdouble) _tmp74_, (gdouble) _tmp77_);
		cairo_fill (ctx);
	}
	_g_object_unref0 (trinket);
}

gboolean
editing_host_page_is_rotate_available (EditingHostPage* self,
                                       Photo* photo)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (photo != NULL, FALSE);
	result = !self->priv->photo_missing;
	return result;
}

static void
editing_host_page_rotate (EditingHostPage* self,
                          Rotation rotation,
                          const gchar* name,
                          const gchar* description)
{
	Dimensions _tmp0_ = {0};
	RotateSingleCommand* command = NULL;
	Photo* _tmp1_;
	Photo* _tmp2_;
	RotateSingleCommand* _tmp3_;
	RotateSingleCommand* _tmp4_;
	CommandManager* _tmp5_;
	CommandManager* _tmp6_;
	RotateSingleCommand* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (description != NULL);
	single_photo_page_cancel_zoom ((SinglePhotoPage*) self);
	dimensions_init (&_tmp0_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp0_, FALSE);
	if (!editing_host_page_has_photo (self)) {
		return;
	}
	_tmp1_ = editing_host_page_get_photo (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = rotate_single_command_new (_tmp2_, rotation, name, description);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp2_);
	command = _tmp4_;
	_tmp5_ = page_get_command_manager ((Page*) self);
	_tmp6_ = _tmp5_;
	_tmp7_ = command;
	command_manager_execute (_tmp6_, (Command*) _tmp7_);
	_command_manager_unref0 (_tmp6_);
	_g_object_unref0 (command);
}

void
editing_host_page_on_rotate_clockwise (EditingHostPage* self)
{
	g_return_if_fail (self != NULL);
	editing_host_page_rotate (self, ROTATION_CLOCKWISE, RESOURCES_ROTATE_CW_FULL_LABEL, RESOURCES_ROTATE_CW_TOOLTIP);
}

void
editing_host_page_on_rotate_counterclockwise (EditingHostPage* self)
{
	g_return_if_fail (self != NULL);
	editing_host_page_rotate (self, ROTATION_COUNTERCLOCKWISE, RESOURCES_ROTATE_CCW_FULL_LABEL, RESOURCES_ROTATE_CCW_TOOLTIP);
}

void
editing_host_page_on_flip_horizontally (EditingHostPage* self)
{
	g_return_if_fail (self != NULL);
	editing_host_page_rotate (self, ROTATION_MIRROR, RESOURCES_HFLIP_LABEL, "");
}

void
editing_host_page_on_flip_vertically (EditingHostPage* self)
{
	g_return_if_fail (self != NULL);
	editing_host_page_rotate (self, ROTATION_UPSIDE_DOWN, RESOURCES_VFLIP_LABEL, "");
}

void
editing_host_page_on_revert (EditingHostPage* self)
{
	Dimensions _tmp0_ = {0};
	Photo* _tmp1_;
	Photo* _tmp2_;
	gboolean _tmp3_;
	RevertSingleCommand* command = NULL;
	Photo* _tmp13_;
	Photo* _tmp14_;
	RevertSingleCommand* _tmp15_;
	RevertSingleCommand* _tmp16_;
	CommandManager* _tmp17_;
	CommandManager* _tmp18_;
	RevertSingleCommand* _tmp19_;
	g_return_if_fail (self != NULL);
	if (self->priv->photo_missing) {
		return;
	}
	dimensions_init (&_tmp0_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp0_, FALSE);
	if (!editing_host_page_has_photo (self)) {
		return;
	}
	_tmp1_ = editing_host_page_get_photo (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = photo_has_editable (_tmp2_);
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		AppWindow* _tmp4_;
		AppWindow* _tmp5_;
		ViewCollection* _tmp6_;
		ViewCollection* _tmp7_;
		GeeCollection* _tmp8_;
		GeeCollection* _tmp9_;
		gboolean _tmp10_;
		Photo* _tmp11_;
		Photo* _tmp12_;
		_tmp4_ = app_window_get_instance ();
		_tmp5_ = _tmp4_;
		_tmp6_ = page_get_view ((Page*) self);
		_tmp7_ = _tmp6_;
		_tmp8_ = view_collection_get_sources (_tmp7_);
		_tmp9_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_COLLECTION, GeeCollection);
		_tmp10_ = !revert_editable_dialog ((GtkWindow*) _tmp5_, _tmp9_);
		_g_object_unref0 (_tmp9_);
		_data_collection_unref0 (_tmp7_);
		_g_object_unref0 (_tmp5_);
		if (_tmp10_) {
			return;
		}
		_tmp11_ = editing_host_page_get_photo (self);
		_tmp12_ = _tmp11_;
		photo_revert_to_master (_tmp12_, TRUE);
		_g_object_unref0 (_tmp12_);
	}
	single_photo_page_cancel_zoom ((SinglePhotoPage*) self);
	editing_host_page_set_photo_missing (self, FALSE);
	_tmp13_ = editing_host_page_get_photo (self);
	_tmp14_ = _tmp13_;
	_tmp15_ = revert_single_command_new (_tmp14_);
	_tmp16_ = _tmp15_;
	_g_object_unref0 (_tmp14_);
	command = _tmp16_;
	_tmp17_ = page_get_command_manager ((Page*) self);
	_tmp18_ = _tmp17_;
	_tmp19_ = command;
	command_manager_execute (_tmp18_, (Command*) _tmp19_);
	_command_manager_unref0 (_tmp18_);
	_g_object_unref0 (command);
}

void
editing_host_page_on_adjust_date_time (EditingHostPage* self)
{
	AdjustDateTimeDialog* dialog = NULL;
	Photo* _tmp0_;
	Photo* _tmp1_;
	AdjustDateTimeDialog* _tmp2_;
	AdjustDateTimeDialog* _tmp3_;
	gint64 time_shift = 0LL;
	gboolean keep_relativity = FALSE;
	gboolean modify_originals = FALSE;
	AdjustDateTimeDialog* _tmp4_;
	gint64 _tmp5_ = 0LL;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_;
	g_return_if_fail (self != NULL);
	if (!editing_host_page_has_photo (self)) {
		return;
	}
	_tmp0_ = editing_host_page_get_photo (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = adjust_date_time_dialog_new ((Dateable*) _tmp1_, 1, !IS_DIRECT_PHOTO_PAGE (self), FALSE, FALSE);
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	dialog = _tmp3_;
	_tmp4_ = dialog;
	_tmp8_ = adjust_date_time_dialog_execute (_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
	time_shift = _tmp5_;
	keep_relativity = _tmp6_;
	modify_originals = _tmp7_;
	if (_tmp8_) {
		ViewCollection* _tmp9_;
		ViewCollection* _tmp10_;
		GeeList* _tmp11_;
		GeeList* _tmp12_;
		AdjustDateTimePhotoCommand* command = NULL;
		Photo* _tmp13_;
		Photo* _tmp14_;
		AdjustDateTimePhotoCommand* _tmp15_;
		AdjustDateTimePhotoCommand* _tmp16_;
		CommandManager* _tmp17_;
		CommandManager* _tmp18_;
		AdjustDateTimePhotoCommand* _tmp19_;
		_tmp9_ = page_get_view ((Page*) self);
		_tmp10_ = _tmp9_;
		_tmp11_ = view_collection_get_selected (_tmp10_);
		_tmp12_ = _tmp11_;
		_g_object_unref0 (_tmp12_);
		_data_collection_unref0 (_tmp10_);
		_tmp13_ = editing_host_page_get_photo (self);
		_tmp14_ = _tmp13_;
		_tmp15_ = adjust_date_time_photo_command_new ((Dateable*) _tmp14_, time_shift, modify_originals);
		_tmp16_ = _tmp15_;
		_g_object_unref0 (_tmp14_);
		command = _tmp16_;
		_tmp17_ = page_get_command_manager ((Page*) self);
		_tmp18_ = _tmp17_;
		_tmp19_ = command;
		command_manager_execute (_tmp18_, (Command*) _tmp19_);
		_command_manager_unref0 (_tmp18_);
		_g_object_unref0 (command);
	}
	_g_object_unref0 (dialog);
}

static guint8*
g_string_get_data (GString* self,
                   gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	const gchar* _tmp0_;
	gint res_length1;
	gint _res_size_;
	guint8* _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->str;
	res = (guint8*) _tmp0_;
	res_length1 = -1;
	_res_size_ = res_length1;
	res_length1 = (gint) self->len;
	_tmp1_ = res;
	_tmp1__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

void
editing_host_page_get_image_data_for_clipboard (GtkClipboard* cb,
                                                GtkSelectionData* sd,
                                                guint info,
                                                void* parent)
{
	gboolean _tmp0_ = FALSE;
	Photo* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (cb != NULL);
	g_return_if_fail (sd != NULL);
	_tmp1_ = editing_host_page_copied_photo;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		Scaling* _tmp2_;
		_tmp2_ = editing_host_page_copied_scaling;
		_tmp0_ = _tmp2_ == NULL;
	}
	if (_tmp0_) {
		g_critical ("EditingHostPage.vala:1639: Attempt to copy image but data for clipboar" \
"d is null");
		return;
	}
	switch (info) {
		case EDITING_HOST_PAGE_TARGET_TYPE_GNOME_COPIED_FILES:
		{
			GString* sb = NULL;
			GString* _tmp3_;
			GString* _tmp4_;
			Photo* _tmp5_;
			GFile* _tmp6_;
			GFile* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			gchar* _tmp11_;
			GString* _tmp12_;
			GString* _tmp13_;
			guint8* _tmp14_;
			gint _tmp14__length1;
			gint _tmp15_ = 0;
			guint8* _tmp16_;
			gint _tmp16__length1;
			_tmp3_ = g_string_new ("copy\n");
			sb = _tmp3_;
			_tmp4_ = sb;
			_tmp5_ = editing_host_page_copied_photo;
			_tmp6_ = media_source_get_file ((MediaSource*) _tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = g_file_get_uri (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = g_uri_escape_string (_tmp9_, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
			_tmp11_ = _tmp10_;
			g_string_append (_tmp4_, _tmp11_);
			_g_free0 (_tmp11_);
			_g_free0 (_tmp9_);
			_g_object_unref0 (_tmp7_);
			_tmp12_ = sb;
			g_string_append (_tmp12_, "\r\n");
			_tmp13_ = sb;
			_tmp14_ = g_string_get_data (_tmp13_, &_tmp15_);
			_tmp14__length1 = _tmp15_;
			_tmp16_ = _tmp14_;
			_tmp16__length1 = _tmp14__length1;
			gtk_selection_data_set (sd, gtk_selection_data_get_target (sd), 8, _tmp16_, (gint) _tmp16__length1);
			_g_string_free0 (sb);
			break;
		}
		case EDITING_HOST_PAGE_TARGET_TYPE_IMAGE:
		{
			{
				GdkPixbuf* pixbuf = NULL;
				Photo* _tmp17_;
				Scaling* _tmp18_;
				Scaling _tmp19_;
				GdkPixbuf* _tmp20_;
				GdkPixbuf* _tmp21_;
				_tmp17_ = editing_host_page_copied_photo;
				_tmp18_ = editing_host_page_copied_scaling;
				_tmp19_ = *_tmp18_;
				_tmp20_ = photo_get_pixbuf_with_options (_tmp17_, &_tmp19_, PHOTO_EXCEPTION_NONE, BACKING_FETCH_MODE_BASELINE, &_inner_error0_);
				pixbuf = _tmp20_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_tmp21_ = pixbuf;
				if (_tmp21_ != NULL) {
					GdkPixbuf* _tmp22_;
					_tmp22_ = pixbuf;
					gtk_selection_data_set_pixbuf (sd, _tmp22_);
				}
				_g_object_unref0 (pixbuf);
			}
			goto __finally0;
			__catch0_g_error:
			{
				g_clear_error (&_inner_error0_);
				g_warning ("EditingHostPage.vala:1659: Unable to get pixbuf when copying image");
				return;
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
			break;
		}
		case EDITING_HOST_PAGE_TARGET_TYPE_TEXT_URI_LIST:
		{
			Photo* _tmp23_;
			GFile* _tmp24_;
			GFile* _tmp25_;
			gchar* _tmp26_;
			gchar** _tmp27_;
			gchar** _tmp28_;
			gint _tmp28__length1;
			_tmp23_ = editing_host_page_copied_photo;
			_tmp24_ = media_source_get_file ((MediaSource*) _tmp23_);
			_tmp25_ = _tmp24_;
			_tmp26_ = g_file_get_uri (_tmp25_);
			_tmp27_ = g_new0 (gchar*, 1 + 1);
			_tmp27_[0] = _tmp26_;
			_tmp28_ = _tmp27_;
			_tmp28__length1 = 1;
			gtk_selection_data_set_uris (sd, _tmp28_);
			_tmp28_ = (_vala_array_free (_tmp28_, _tmp28__length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_tmp25_);
			break;
		}
		case EDITING_HOST_PAGE_TARGET_TYPE_TEXT:
		{
			Photo* _tmp29_;
			GFile* _tmp30_;
			GFile* _tmp31_;
			gchar* _tmp32_;
			gchar* _tmp33_;
			_tmp29_ = editing_host_page_copied_photo;
			_tmp30_ = media_source_get_file ((MediaSource*) _tmp29_);
			_tmp31_ = _tmp30_;
			_tmp32_ = g_file_get_uri (_tmp31_);
			_tmp33_ = _tmp32_;
			gtk_selection_data_set_text (sd, _tmp33_, -1);
			_g_free0 (_tmp33_);
			_g_object_unref0 (_tmp31_);
			break;
		}
		default:
		{
			break;
		}
	}
}

void
editing_host_page_get_metadata_for_clipboard (GtkClipboard* cb,
                                              GtkSelectionData* sd,
                                              guint info,
                                              void* parent)
{
	gboolean _tmp0_ = FALSE;
	Photo* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (cb != NULL);
	g_return_if_fail (sd != NULL);
	_tmp1_ = editing_host_page_copied_photo;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		Scaling* _tmp2_;
		_tmp2_ = editing_host_page_copied_scaling;
		_tmp0_ = _tmp2_ == NULL;
	}
	if (_tmp0_) {
		g_critical ("EditingHostPage.vala:1680: Attempt to copy image but data for clipboar" \
"d is null");
		return;
	}
	switch (info) {
		case EDITING_HOST_PAGE_TARGET_TYPE_TEXT:
		{
			GString* sb = NULL;
			Photo* _tmp3_;
			gchar* _tmp4_;
			gchar* _tmp5_;
			GString* _tmp6_;
			GString* _tmp7_;
			gchar* title = NULL;
			Photo* _tmp8_;
			gchar* _tmp9_;
			const gchar* _tmp10_;
			gchar* comment = NULL;
			Photo* _tmp17_;
			gchar* _tmp18_;
			const gchar* _tmp19_;
			Dimensions dim = {0};
			Photo* _tmp24_;
			Dimensions _tmp25_ = {0};
			GString* _tmp26_;
			Dimensions _tmp27_;
			Dimensions _tmp28_;
			gchar* _tmp29_;
			gchar* _tmp30_;
			gchar* _tmp31_;
			gchar* _tmp32_;
			PhotoMetadata* metadata = NULL;
			Photo* _tmp44_;
			PhotoMetadata* _tmp45_;
			GeeCollection* tags = NULL;
			PhotoMetadata* _tmp46_;
			GeeCollection* _tmp47_;
			GeeCollection* _tmp48_;
			GString* _tmp76_;
			const gchar* _tmp77_;
			GString* _tmp78_;
			_tmp3_ = editing_host_page_copied_photo;
			_tmp4_ = media_source_get_basename ((MediaSource*) _tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = g_string_new (_tmp5_);
			_tmp7_ = _tmp6_;
			_g_free0 (_tmp5_);
			sb = _tmp7_;
			_tmp8_ = editing_host_page_copied_photo;
			_tmp9_ = media_source_get_title ((MediaSource*) _tmp8_);
			title = _tmp9_;
			_tmp10_ = title;
			if (_tmp10_ != NULL) {
				GString* _tmp11_;
				Photo* _tmp12_;
				gchar* _tmp13_;
				gchar* _tmp14_;
				gchar* _tmp15_;
				gchar* _tmp16_;
				_tmp11_ = sb;
				_tmp12_ = editing_host_page_copied_photo;
				_tmp13_ = media_source_get_title ((MediaSource*) _tmp12_);
				_tmp14_ = _tmp13_;
				_tmp15_ = g_strconcat (_tmp14_, "\n", NULL);
				_tmp16_ = _tmp15_;
				g_string_append (_tmp11_, _tmp16_);
				_g_free0 (_tmp16_);
				_g_free0 (_tmp14_);
			}
			_tmp17_ = editing_host_page_copied_photo;
			_tmp18_ = media_source_get_comment ((MediaSource*) _tmp17_);
			comment = _tmp18_;
			_tmp19_ = comment;
			if (_tmp19_ != NULL) {
				GString* _tmp20_;
				const gchar* _tmp21_;
				gchar* _tmp22_;
				gchar* _tmp23_;
				_tmp20_ = sb;
				_tmp21_ = comment;
				_tmp22_ = g_strconcat (_tmp21_, "\n", NULL);
				_tmp23_ = _tmp22_;
				g_string_append (_tmp20_, _tmp23_);
				_g_free0 (_tmp23_);
			}
			_tmp24_ = editing_host_page_copied_photo;
			photo_get_raw_dimensions (_tmp24_, &_tmp25_);
			dim = _tmp25_;
			_tmp26_ = sb;
			_tmp27_ = dim;
			_tmp28_ = dim;
			_tmp29_ = g_strdup_printf (_ ("Raw dimensions: %i x %i px"), _tmp27_.width, _tmp28_.height);
			_tmp30_ = _tmp29_;
			_tmp31_ = g_strconcat (_tmp30_, "\n", NULL);
			_tmp32_ = _tmp31_;
			g_string_append (_tmp26_, _tmp32_);
			_g_free0 (_tmp32_);
			_g_free0 (_tmp30_);
			{
				GdkPixbuf* pixbuf = NULL;
				Photo* _tmp33_;
				Scaling* _tmp34_;
				Scaling _tmp35_;
				GdkPixbuf* _tmp36_;
				GString* _tmp37_;
				GdkPixbuf* _tmp38_;
				GdkPixbuf* _tmp39_;
				gchar* _tmp40_;
				gchar* _tmp41_;
				gchar* _tmp42_;
				gchar* _tmp43_;
				_tmp33_ = editing_host_page_copied_photo;
				_tmp34_ = editing_host_page_copied_scaling;
				_tmp35_ = *_tmp34_;
				_tmp36_ = photo_get_pixbuf_with_options (_tmp33_, &_tmp35_, PHOTO_EXCEPTION_NONE, BACKING_FETCH_MODE_BASELINE, &_inner_error0_);
				pixbuf = _tmp36_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_tmp37_ = sb;
				_tmp38_ = pixbuf;
				_tmp39_ = pixbuf;
				_tmp40_ = g_strdup_printf (_ ("Copied dimensions: %i x %i px"), gdk_pixbuf_get_width (_tmp38_), gdk_pixbuf_get_height (_tmp39_));
				_tmp41_ = _tmp40_;
				_tmp42_ = g_strconcat (_tmp41_, "\n\n", NULL);
				_tmp43_ = _tmp42_;
				g_string_append (_tmp37_, _tmp43_);
				_g_free0 (_tmp43_);
				_g_free0 (_tmp41_);
				_g_object_unref0 (pixbuf);
			}
			goto __finally0;
			__catch0_g_error:
			{
				g_clear_error (&_inner_error0_);
				g_warning ("EditingHostPage.vala:1703: Unable to get pixbuf dimensions when copyin" \
"g image metadata");
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_free0 (comment);
				_g_free0 (title);
				_g_string_free0 (sb);
				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;
			}
			_tmp44_ = editing_host_page_copied_photo;
			_tmp45_ = photo_source_get_metadata ((PhotoSource*) _tmp44_);
			metadata = _tmp45_;
			_tmp46_ = metadata;
			_tmp47_ = photo_metadata_get_all_tags (_tmp46_, NULL, NULL, NULL);
			tags = _tmp47_;
			_tmp48_ = tags;
			if (_tmp48_ != NULL) {
				GeeTreeSet* ts = NULL;
				GeeTreeSet* _tmp49_;
				_tmp49_ = gee_tree_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
				ts = _tmp49_;
				{
					GeeIterator* _s_it = NULL;
					GeeCollection* _tmp50_;
					GeeIterator* _tmp51_;
					_tmp50_ = tags;
					_tmp51_ = gee_iterable_iterator ((GeeIterable*) _tmp50_);
					_s_it = _tmp51_;
					while (TRUE) {
						GeeIterator* _tmp52_;
						gchar* s = NULL;
						GeeIterator* _tmp53_;
						gpointer _tmp54_;
						GeeTreeSet* _tmp55_;
						PhotoMetadata* _tmp56_;
						const gchar* _tmp57_;
						gchar* _tmp58_;
						gchar* _tmp59_;
						PhotoMetadata* _tmp60_;
						const gchar* _tmp61_;
						gchar* _tmp62_;
						gchar* _tmp63_;
						gchar* _tmp64_;
						gchar* _tmp65_;
						_tmp52_ = _s_it;
						if (!gee_iterator_next (_tmp52_)) {
							break;
						}
						_tmp53_ = _s_it;
						_tmp54_ = gee_iterator_get (_tmp53_);
						s = (gchar*) _tmp54_;
						_tmp55_ = ts;
						_tmp56_ = metadata;
						_tmp57_ = s;
						_tmp58_ = photo_metadata_get_tag_label (_tmp56_, _tmp57_);
						_tmp59_ = _tmp58_;
						_tmp60_ = metadata;
						_tmp61_ = s;
						_tmp62_ = photo_metadata_get_string_interpreted (_tmp60_, _tmp61_, PHOTO_METADATA_PREPARE_STRING_OPTIONS);
						_tmp63_ = _tmp62_;
						_tmp64_ = g_strdup_printf ("%s: %s", _tmp59_, _tmp63_);
						_tmp65_ = _tmp64_;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp55_, _tmp65_);
						_g_free0 (_tmp65_);
						_g_free0 (_tmp63_);
						_g_free0 (_tmp59_);
						_g_free0 (s);
					}
					_g_object_unref0 (_s_it);
				}
				{
					GeeIterator* _s_it = NULL;
					GeeTreeSet* _tmp66_;
					GeeIterator* _tmp67_;
					_tmp66_ = ts;
					_tmp67_ = gee_abstract_collection_iterator ((GeeAbstractCollection*) _tmp66_);
					_s_it = _tmp67_;
					while (TRUE) {
						GeeIterator* _tmp68_;
						gchar* s = NULL;
						GeeIterator* _tmp69_;
						gpointer _tmp70_;
						GString* _tmp71_;
						const gchar* _tmp72_;
						gchar* _tmp73_;
						gchar* _tmp74_;
						_tmp68_ = _s_it;
						if (!gee_iterator_next (_tmp68_)) {
							break;
						}
						_tmp69_ = _s_it;
						_tmp70_ = gee_iterator_get (_tmp69_);
						s = (gchar*) _tmp70_;
						_tmp71_ = sb;
						_tmp72_ = s;
						_tmp73_ = g_strconcat (_tmp72_, "\n", NULL);
						_tmp74_ = _tmp73_;
						g_string_append (_tmp71_, _tmp74_);
						_g_free0 (_tmp74_);
						_g_free0 (s);
					}
					_g_object_unref0 (_s_it);
				}
				_g_object_unref0 (ts);
			} else {
				GString* _tmp75_;
				_tmp75_ = sb;
				g_string_append (_tmp75_, _ ("No metadata found"));
			}
			_tmp76_ = sb;
			_tmp77_ = _tmp76_->str;
			_tmp78_ = sb;
			gtk_selection_data_set_text (sd, _tmp77_, ((gint) _tmp78_->len) - 1);
			_g_object_unref0 (tags);
			_media_metadata_unref0 (metadata);
			_g_free0 (comment);
			_g_free0 (title);
			_g_string_free0 (sb);
			break;
		}
		default:
		{
			break;
		}
	}
}

void
editing_host_page_clear_data_for_clipboard (GtkClipboard* cb,
                                            void* parent)
{
	g_return_if_fail (cb != NULL);
	_g_object_unref0 (editing_host_page_copied_photo);
	editing_host_page_copied_photo = NULL;
	_scaling_free0 (editing_host_page_copied_scaling);
	editing_host_page_copied_scaling = NULL;
}

static gpointer
_scaling_dup0 (gpointer self)
{
	return self ? scaling_dup (self) : NULL;
}

static void
_editing_host_page_get_image_data_for_clipboard_gtk_clipboard_get_func (GtkClipboard* clipboard,
                                                                        GtkSelectionData* selection_data,
                                                                        guint info,
                                                                        void* user_data_or_owner)
{
	editing_host_page_get_image_data_for_clipboard (clipboard, selection_data, info, user_data_or_owner);
}

static void
_editing_host_page_clear_data_for_clipboard_gtk_clipboard_clear_func (GtkClipboard* clipboard,
                                                                      void* user_data_or_owner)
{
	editing_host_page_clear_data_for_clipboard (clipboard, user_data_or_owner);
}

void
editing_host_page_on_copy_image (EditingHostPage* self)
{
	GtkClipboard* _tmp0_;
	Photo* _tmp1_;
	Photo* _tmp2_;
	Scaling _tmp3_ = {0};
	Scaling* _tmp4_;
	GtkClipboard* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = editing_host_page_clipboard;
	gtk_clipboard_clear (_tmp0_);
	_tmp1_ = editing_host_page_get_photo (self);
	_g_object_unref0 (editing_host_page_copied_photo);
	editing_host_page_copied_photo = _tmp1_;
	_tmp2_ = editing_host_page_copied_photo;
	if (_tmp2_ == NULL) {
		return;
	}
	single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp3_);
	_tmp4_ = _scaling_dup0 (&_tmp3_);
	_scaling_free0 (editing_host_page_copied_scaling);
	editing_host_page_copied_scaling = _tmp4_;
	_tmp5_ = editing_host_page_clipboard;
	gtk_clipboard_set_with_owner (_tmp5_, EDITING_HOST_PAGE_COPY_TARGETS, (guint) G_N_ELEMENTS (EDITING_HOST_PAGE_COPY_TARGETS), _editing_host_page_get_image_data_for_clipboard_gtk_clipboard_get_func, _editing_host_page_clear_data_for_clipboard_gtk_clipboard_clear_func, (GObject*) self);
}

static void
_editing_host_page_get_metadata_for_clipboard_gtk_clipboard_get_func (GtkClipboard* clipboard,
                                                                      GtkSelectionData* selection_data,
                                                                      guint info,
                                                                      void* user_data_or_owner)
{
	editing_host_page_get_metadata_for_clipboard (clipboard, selection_data, info, user_data_or_owner);
}

void
editing_host_page_on_copy_metadata (EditingHostPage* self)
{
	GtkClipboard* _tmp0_;
	Photo* _tmp1_;
	Photo* _tmp2_;
	Scaling _tmp3_ = {0};
	Scaling* _tmp4_;
	GtkClipboard* _tmp5_;
	GtkTargetEntry _tmp6_ = {0};
	GtkTargetEntry* _tmp7_;
	GtkTargetEntry* _tmp8_;
	gint _tmp8__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = editing_host_page_clipboard;
	gtk_clipboard_clear (_tmp0_);
	_tmp1_ = editing_host_page_get_photo (self);
	_g_object_unref0 (editing_host_page_copied_photo);
	editing_host_page_copied_photo = _tmp1_;
	_tmp2_ = editing_host_page_copied_photo;
	if (_tmp2_ == NULL) {
		return;
	}
	single_photo_page_get_canvas_scaling ((SinglePhotoPage*) self, &_tmp3_);
	_tmp4_ = _scaling_dup0 (&_tmp3_);
	_scaling_free0 (editing_host_page_copied_scaling);
	editing_host_page_copied_scaling = _tmp4_;
	_tmp5_ = editing_host_page_clipboard;
	memset (&_tmp6_, 0, sizeof (GtkTargetEntry));
	_tmp6_.target = "UTF8_STRING";
	_tmp6_.flags = (guint) GTK_TARGET_OTHER_APP;
	_tmp6_.info = (guint) EDITING_HOST_PAGE_TARGET_TYPE_TEXT;
	_tmp7_ = g_new0 (GtkTargetEntry, 1);
	_tmp7_[0] = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp8__length1 = 1;
	gtk_clipboard_set_with_owner (_tmp5_, _tmp8_, (guint) 1, _editing_host_page_get_metadata_for_clipboard_gtk_clipboard_get_func, _editing_host_page_clear_data_for_clipboard_gtk_clipboard_clear_func, (GObject*) self);
	_tmp8_ = (g_free (_tmp8_), NULL);
}

static void
_editing_host_page_on_rotate_counterclockwise_gtk_button_clicked (GtkButton* _sender,
                                                                  gpointer self)
{
	editing_host_page_on_rotate_counterclockwise ((EditingHostPage*) self);
}

static void
_editing_host_page_on_flip_vertically_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self)
{
	editing_host_page_on_flip_vertically ((EditingHostPage*) self);
}

static gboolean
editing_host_page_real_on_ctrl_pressed (Page* base,
                                        GdkEventKey* event)
{
	EditingHostPage * self;
	GtkButton* _tmp0_;
	GtkImage* _tmp1_;
	GtkImage* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	guint _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	GtkImage* _tmp9_;
	GtkImage* _tmp10_;
	GtkButton* _tmp11_;
	GtkButton* _tmp12_;
	guint _tmp13_;
	GtkButton* _tmp14_;
	EditingToolsEditingTool* _tmp15_;
	gboolean result;
	self = (EditingHostPage*) base;
	_tmp0_ = self->rotate_button;
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("object-rotate-left", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp1_);
	_tmp2_ = _tmp1_;
	gtk_button_set_image (_tmp0_, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = self->rotate_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp3_, RESOURCES_ROTATE_CCW_TOOLTIP);
	_tmp4_ = self->rotate_button;
	gtk_widget_show_all ((GtkWidget*) _tmp4_);
	_tmp5_ = self->rotate_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp6_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp5_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp6_, 0, NULL, (GCallback) _editing_host_page_on_rotate_clockwise_gtk_button_clicked, self);
	_tmp7_ = self->rotate_button;
	g_signal_connect_object (_tmp7_, "clicked", (GCallback) _editing_host_page_on_rotate_counterclockwise_gtk_button_clicked, self, 0);
	_tmp8_ = self->priv->flip_button;
	_tmp9_ = (GtkImage*) gtk_image_new_from_icon_name (RESOURCES_VFLIP, (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp9_);
	_tmp10_ = _tmp9_;
	gtk_button_set_image (_tmp8_, (GtkWidget*) _tmp10_);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = self->priv->flip_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp11_, RESOURCES_VFLIP_TOOLTIP);
	_tmp12_ = self->priv->flip_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp13_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp12_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp13_, 0, NULL, (GCallback) _editing_host_page_on_flip_horizontally_gtk_button_clicked, self);
	_tmp14_ = self->priv->flip_button;
	g_signal_connect_object (_tmp14_, "clicked", (GCallback) _editing_host_page_on_flip_vertically_gtk_button_clicked, self, 0);
	_tmp15_ = self->priv->current_tool;
	if (_tmp15_ == NULL) {
		editing_host_page_swap_out_original (self);
	}
	result = PAGE_CLASS (editing_host_page_parent_class)->on_ctrl_pressed ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), event);
	return result;
}

static gboolean
editing_host_page_real_on_ctrl_released (Page* base,
                                         GdkEventKey* event)
{
	EditingHostPage * self;
	GtkButton* _tmp0_;
	GtkImage* _tmp1_;
	GtkImage* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	guint _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	GtkImage* _tmp9_;
	GtkImage* _tmp10_;
	GtkButton* _tmp11_;
	GtkButton* _tmp12_;
	guint _tmp13_;
	GtkButton* _tmp14_;
	gboolean _tmp15_ = FALSE;
	gboolean _tmp16_ = FALSE;
	EditingToolsEditingTool* _tmp17_;
	gboolean result;
	self = (EditingHostPage*) base;
	_tmp0_ = self->rotate_button;
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("object-rotate-right", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp1_);
	_tmp2_ = _tmp1_;
	gtk_button_set_image (_tmp0_, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = self->rotate_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp3_, RESOURCES_ROTATE_CW_TOOLTIP);
	_tmp4_ = self->rotate_button;
	gtk_widget_show_all ((GtkWidget*) _tmp4_);
	_tmp5_ = self->rotate_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp6_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp5_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp6_, 0, NULL, (GCallback) _editing_host_page_on_rotate_counterclockwise_gtk_button_clicked, self);
	_tmp7_ = self->rotate_button;
	g_signal_connect_object (_tmp7_, "clicked", (GCallback) _editing_host_page_on_rotate_clockwise_gtk_button_clicked, self, 0);
	_tmp8_ = self->priv->flip_button;
	_tmp9_ = (GtkImage*) gtk_image_new_from_icon_name (RESOURCES_HFLIP, (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp9_);
	_tmp10_ = _tmp9_;
	gtk_button_set_image (_tmp8_, (GtkWidget*) _tmp10_);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = self->priv->flip_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp11_, RESOURCES_HFLIP_TOOLTIP);
	_tmp12_ = self->priv->flip_button;
	g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp13_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp12_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp13_, 0, NULL, (GCallback) _editing_host_page_on_flip_vertically_gtk_button_clicked, self);
	_tmp14_ = self->priv->flip_button;
	g_signal_connect_object (_tmp14_, "clicked", (GCallback) _editing_host_page_on_flip_horizontally_gtk_button_clicked, self, 0);
	_tmp17_ = self->priv->current_tool;
	if (_tmp17_ == NULL) {
		_tmp16_ = page_get_shift_pressed ((Page*) self);
	} else {
		_tmp16_ = FALSE;
	}
	if (_tmp16_) {
		_tmp15_ = !page_get_alt_pressed ((Page*) self);
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		editing_host_page_swap_in_original (self);
	}
	result = PAGE_CLASS (editing_host_page_parent_class)->on_ctrl_released ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_SINGLE_PHOTO_PAGE, SinglePhotoPage), event);
	return result;
}

void
editing_host_page_on_tool_button_toggled (EditingHostPage* self,
                                          GtkToggleButton* toggle,
                                          EditingToolsEditingToolFactory factory)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean deactivating_only = FALSE;
	Dimensions _tmp4_ = {0};
	GtkToggleButton* _tmp5_;
	EditingToolsEditingTool* tool = NULL;
	EditingToolsEditingTool* _tmp6_;
	EditingToolsEditingTool* _tmp7_;
	EditingToolsEditingTool* _tmp8_;
	EditingToolsEditingTool* _tmp9_;
	EditingToolsEditingTool* _tmp10_;
	EditingToolsEditingTool* _tmp11_;
	EditingToolsEditingTool* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (toggle != NULL);
	_tmp1_ = gtk_toggle_button_get_active (toggle);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		GtkToggleButton* _tmp3_;
		_tmp3_ = self->priv->current_editing_toggle;
		_tmp0_ = _tmp3_ == toggle;
	} else {
		_tmp0_ = FALSE;
	}
	deactivating_only = _tmp0_;
	dimensions_init (&_tmp4_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp4_, FALSE);
	if (deactivating_only) {
		page_restore_cursor_hiding ((Page*) self);
		return;
	}
	page_suspend_cursor_hiding ((Page*) self);
	_tmp5_ = _g_object_ref0 (toggle);
	_g_object_unref0 (self->priv->current_editing_toggle);
	self->priv->current_editing_toggle = _tmp5_;
	_tmp6_ = factory ();
	tool = _tmp6_;
	_tmp7_ = tool;
	g_signal_connect_object (_tmp7_, "activated", (GCallback) _editing_host_page_on_tool_activated_editing_tools_editing_tool_activated, self, 0);
	_tmp8_ = tool;
	g_signal_connect_object (_tmp8_, "deactivated", (GCallback) _editing_host_page_on_tool_deactivated_editing_tools_editing_tool_deactivated, self, 0);
	_tmp9_ = tool;
	g_signal_connect_object (_tmp9_, "applied", (GCallback) _editing_host_page_on_tool_applied_editing_tools_editing_tool_applied, self, 0);
	_tmp10_ = tool;
	g_signal_connect_object (_tmp10_, "cancelled", (GCallback) _editing_host_page_on_tool_cancelled_editing_tools_editing_tool_cancelled, self, 0);
	_tmp11_ = tool;
	g_signal_connect_object (_tmp11_, "aborted", (GCallback) _editing_host_page_on_tool_aborted_editing_tools_editing_tool_aborted, self, 0);
	_tmp12_ = tool;
	editing_host_page_activate_tool (self, _tmp12_);
	_g_object_unref0 (tool);
}

static void
editing_host_page_on_tool_activated (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	SliderAssembly* _tmp1_;
	GtkToggleButton* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_editing_toggle;
	_vala_assert (_tmp0_ != NULL, "current_editing_toggle != null");
	_tmp1_ = self->priv->zoom_assembly;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, FALSE);
	_tmp2_ = self->priv->current_editing_toggle;
	gtk_toggle_button_set_active (_tmp2_, TRUE);
}

static void
editing_host_page_on_tool_deactivated (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	SliderAssembly* _tmp1_;
	GtkToggleButton* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_editing_toggle;
	_vala_assert (_tmp0_ != NULL, "current_editing_toggle != null");
	_tmp1_ = self->priv->zoom_assembly;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, TRUE);
	_tmp2_ = self->priv->current_editing_toggle;
	gtk_toggle_button_set_active (_tmp2_, FALSE);
}

static void
editing_host_page_on_tool_applied (EditingHostPage* self,
                                   Command* command,
                                   GdkPixbuf* new_pixbuf,
                                   Dimensions* new_max_dim,
                                   gboolean needs_improvement)
{
	Dimensions _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (new_max_dim != NULL);
	_tmp0_ = *new_max_dim;
	editing_host_page_deactivate_tool (self, command, new_pixbuf, &_tmp0_, needs_improvement);
}

static void
editing_host_page_on_tool_cancelled (EditingHostPage* self)
{
	Dimensions _tmp0_ = {0};
	g_return_if_fail (self != NULL);
	dimensions_init (&_tmp0_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp0_, FALSE);
	editing_host_page_update_enhance_action (self);
	single_photo_page_restore_zoom_state ((SinglePhotoPage*) self);
	single_photo_page_repaint ((SinglePhotoPage*) self, NULL);
}

static void
editing_host_page_on_tool_aborted (EditingHostPage* self)
{
	Dimensions _tmp0_ = {0};
	g_return_if_fail (self != NULL);
	dimensions_init (&_tmp0_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp0_, FALSE);
	editing_host_page_set_photo_missing (self, TRUE);
}

void
editing_host_page_toggle_crop (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	GtkToggleButton* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->crop_button;
	_tmp1_ = self->priv->crop_button;
	gtk_toggle_button_set_active (_tmp0_, !gtk_toggle_button_get_active (_tmp1_));
}

void
editing_host_page_toggle_straighten (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	GtkToggleButton* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->straighten_button;
	_tmp1_ = self->priv->straighten_button;
	gtk_toggle_button_set_active (_tmp0_, !gtk_toggle_button_get_active (_tmp1_));
}

void
editing_host_page_toggle_redeye (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	GtkToggleButton* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->redeye_button;
	_tmp1_ = self->priv->redeye_button;
	gtk_toggle_button_set_active (_tmp0_, !gtk_toggle_button_get_active (_tmp1_));
}

void
editing_host_page_toggle_adjust (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	GtkToggleButton* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->adjust_button;
	_tmp1_ = self->priv->adjust_button;
	gtk_toggle_button_set_active (_tmp0_, !gtk_toggle_button_get_active (_tmp1_));
}

static EditingToolsEditingTool*
_editing_tools_straighten_tool_factory_editing_tools_editing_tool_factory (void)
{
	EditingToolsEditingTool* result;
	result = editing_tools_straighten_tool_factory ();
	return result;
}

static void
editing_host_page_on_straighten_toggled (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->straighten_button;
	editing_host_page_on_tool_button_toggled (self, _tmp0_, _editing_tools_straighten_tool_factory_editing_tools_editing_tool_factory);
}

static EditingToolsEditingTool*
_editing_tools_crop_tool_factory_editing_tools_editing_tool_factory (void)
{
	EditingToolsEditingTool* result;
	result = editing_tools_crop_tool_factory ();
	return result;
}

static void
editing_host_page_on_crop_toggled (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->crop_button;
	editing_host_page_on_tool_button_toggled (self, _tmp0_, _editing_tools_crop_tool_factory_editing_tools_editing_tool_factory);
}

static EditingToolsEditingTool*
_editing_tools_redeye_tool_factory_editing_tools_editing_tool_factory (void)
{
	EditingToolsEditingTool* result;
	result = editing_tools_redeye_tool_factory ();
	return result;
}

static void
editing_host_page_on_redeye_toggled (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->redeye_button;
	editing_host_page_on_tool_button_toggled (self, _tmp0_, _editing_tools_redeye_tool_factory_editing_tools_editing_tool_factory);
}

static EditingToolsEditingTool*
_editing_tools_adjust_tool_factory_editing_tools_editing_tool_factory (void)
{
	EditingToolsEditingTool* result;
	result = editing_tools_adjust_tool_factory ();
	return result;
}

static void
editing_host_page_on_adjust_toggled (EditingHostPage* self)
{
	GtkToggleButton* _tmp0_;
	GtkToggleButton* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->adjust_button;
	editing_host_page_on_tool_button_toggled (self, _tmp0_, _editing_tools_adjust_tool_factory_editing_tools_editing_tool_factory);
	_tmp1_ = self->priv->adjust_button;
	_tmp2_ = gtk_toggle_button_get_active (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		GtkToggleButton* _tmp4_;
		guint _tmp5_;
		GtkToggleButton* _tmp6_;
		GtkToggleButton* _tmp7_;
		_tmp4_ = self->enhance_button;
		g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp5_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkButton*) _tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _editing_host_page_on_enhance_gtk_button_clicked, self);
		_tmp6_ = self->enhance_button;
		gtk_toggle_button_set_active (_tmp6_, FALSE);
		_tmp7_ = self->enhance_button;
		g_signal_connect_object ((GtkButton*) _tmp7_, "clicked", (GCallback) _editing_host_page_on_enhance_gtk_button_clicked, self, 0);
	}
}

gboolean
editing_host_page_is_enhance_available (EditingHostPage* self,
                                        Photo* photo)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (photo != NULL, FALSE);
	result = !self->priv->photo_missing;
	return result;
}

void
editing_host_page_on_enhance (EditingHostPage* self)
{
	EditingToolsEditingTool* _tmp0_;
	EditingToolsAdjustTool* adjust_tool = NULL;
	EditingToolsEditingTool* _tmp2_;
	EditingToolsAdjustTool* _tmp3_;
	EditingToolsAdjustTool* _tmp4_;
	Photo* _tmp10_;
	Photo* _tmp11_;
	gboolean _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_tool;
	if (!EDITING_TOOLS_IS_ADJUST_TOOL (_tmp0_)) {
		Dimensions _tmp1_ = {0};
		dimensions_init (&_tmp1_, 0, 0);
		editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp1_, FALSE);
		single_photo_page_cancel_zoom ((SinglePhotoPage*) self);
	}
	if (!editing_host_page_has_photo (self)) {
		return;
	}
	_tmp2_ = self->priv->current_tool;
	_tmp3_ = _g_object_ref0 (EDITING_TOOLS_IS_ADJUST_TOOL (_tmp2_) ? ((EditingToolsAdjustTool*) _tmp2_) : NULL);
	adjust_tool = _tmp3_;
	_tmp4_ = adjust_tool;
	if (_tmp4_ != NULL) {
		EditingToolsAdjustTool* _tmp5_;
		GtkToggleButton* _tmp6_;
		guint _tmp7_;
		GtkToggleButton* _tmp8_;
		GtkToggleButton* _tmp9_;
		_tmp5_ = adjust_tool;
		editing_tools_adjust_tool_enhance (_tmp5_);
		_tmp6_ = self->enhance_button;
		g_signal_parse_name ("clicked", gtk_button_get_type (), &_tmp7_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkButton*) _tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _editing_host_page_on_enhance_gtk_button_clicked, self);
		_tmp8_ = self->enhance_button;
		gtk_toggle_button_set_active (_tmp8_, FALSE);
		_tmp9_ = self->enhance_button;
		g_signal_connect_object ((GtkButton*) _tmp9_, "clicked", (GCallback) _editing_host_page_on_enhance_gtk_button_clicked, self, 0);
		_g_object_unref0 (adjust_tool);
		return;
	}
	_tmp10_ = editing_host_page_get_photo (self);
	_tmp11_ = _tmp10_;
	_tmp12_ = photo_is_enhanced (_tmp11_);
	_g_object_unref0 (_tmp11_);
	if (_tmp12_) {
		EnhanceSingleCommand* cmd = NULL;
		CommandManager* _tmp13_;
		CommandManager* _tmp14_;
		Command* _tmp15_;
		EnhanceSingleCommand* _tmp16_;
		EnhanceSingleCommand* _tmp17_;
		gboolean _tmp18_ = FALSE;
		EnhanceSingleCommand* _tmp19_;
		Photo* _tmp33_;
		Photo* _tmp34_;
		_tmp13_ = page_get_command_manager ((Page*) self);
		_tmp14_ = _tmp13_;
		_tmp15_ = command_manager_get_undo_command (_tmp14_);
		_tmp16_ = IS_ENHANCE_SINGLE_COMMAND (_tmp15_) ? ((EnhanceSingleCommand*) _tmp15_) : NULL;
		if (_tmp16_ == NULL) {
			_g_object_unref0 (_tmp15_);
		}
		_tmp17_ = _tmp16_;
		_command_manager_unref0 (_tmp14_);
		cmd = _tmp17_;
		_tmp19_ = cmd;
		if (_tmp19_ != NULL) {
			EnhanceSingleCommand* _tmp20_;
			DataSource* _tmp21_;
			Photo* _tmp22_;
			Photo* _tmp23_;
			_tmp20_ = cmd;
			_tmp21_ = ((SingleDataSourceCommand*) _tmp20_)->source;
			_tmp22_ = editing_host_page_get_photo (self);
			_tmp23_ = _tmp22_;
			_tmp18_ = _tmp21_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, TYPE_DATA_SOURCE, DataSource);
			_g_object_unref0 (_tmp23_);
		} else {
			_tmp18_ = FALSE;
		}
		if (_tmp18_) {
			CommandManager* _tmp24_;
			CommandManager* _tmp25_;
			_tmp24_ = page_get_command_manager ((Page*) self);
			_tmp25_ = _tmp24_;
			command_manager_undo (_tmp25_);
			_command_manager_unref0 (_tmp25_);
		} else {
			UnEnhanceSingleCommand* command = NULL;
			Photo* _tmp26_;
			Photo* _tmp27_;
			UnEnhanceSingleCommand* _tmp28_;
			UnEnhanceSingleCommand* _tmp29_;
			CommandManager* _tmp30_;
			CommandManager* _tmp31_;
			UnEnhanceSingleCommand* _tmp32_;
			_tmp26_ = editing_host_page_get_photo (self);
			_tmp27_ = _tmp26_;
			_tmp28_ = un_enhance_single_command_new (_tmp27_);
			_tmp29_ = _tmp28_;
			_g_object_unref0 (_tmp27_);
			command = _tmp29_;
			_tmp30_ = page_get_command_manager ((Page*) self);
			_tmp31_ = _tmp30_;
			_tmp32_ = command;
			command_manager_execute (_tmp31_, (Command*) _tmp32_);
			_command_manager_unref0 (_tmp31_);
			_g_object_unref0 (command);
		}
		_tmp33_ = editing_host_page_get_photo (self);
		_tmp34_ = _tmp33_;
		photo_set_enhanced (_tmp34_, FALSE);
		_g_object_unref0 (_tmp34_);
		_g_object_unref0 (cmd);
	} else {
		UnEnhanceSingleCommand* cmd = NULL;
		CommandManager* _tmp35_;
		CommandManager* _tmp36_;
		Command* _tmp37_;
		UnEnhanceSingleCommand* _tmp38_;
		UnEnhanceSingleCommand* _tmp39_;
		gboolean _tmp40_ = FALSE;
		UnEnhanceSingleCommand* _tmp41_;
		Photo* _tmp55_;
		Photo* _tmp56_;
		_tmp35_ = page_get_command_manager ((Page*) self);
		_tmp36_ = _tmp35_;
		_tmp37_ = command_manager_get_undo_command (_tmp36_);
		_tmp38_ = IS_UN_ENHANCE_SINGLE_COMMAND (_tmp37_) ? ((UnEnhanceSingleCommand*) _tmp37_) : NULL;
		if (_tmp38_ == NULL) {
			_g_object_unref0 (_tmp37_);
		}
		_tmp39_ = _tmp38_;
		_command_manager_unref0 (_tmp36_);
		cmd = _tmp39_;
		_tmp41_ = cmd;
		if (_tmp41_ != NULL) {
			UnEnhanceSingleCommand* _tmp42_;
			DataSource* _tmp43_;
			Photo* _tmp44_;
			Photo* _tmp45_;
			_tmp42_ = cmd;
			_tmp43_ = ((SingleDataSourceCommand*) _tmp42_)->source;
			_tmp44_ = editing_host_page_get_photo (self);
			_tmp45_ = _tmp44_;
			_tmp40_ = _tmp43_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp45_, TYPE_DATA_SOURCE, DataSource);
			_g_object_unref0 (_tmp45_);
		} else {
			_tmp40_ = FALSE;
		}
		if (_tmp40_) {
			CommandManager* _tmp46_;
			CommandManager* _tmp47_;
			_tmp46_ = page_get_command_manager ((Page*) self);
			_tmp47_ = _tmp46_;
			command_manager_undo (_tmp47_);
			_command_manager_unref0 (_tmp47_);
		} else {
			EnhanceSingleCommand* command = NULL;
			Photo* _tmp48_;
			Photo* _tmp49_;
			EnhanceSingleCommand* _tmp50_;
			EnhanceSingleCommand* _tmp51_;
			CommandManager* _tmp52_;
			CommandManager* _tmp53_;
			EnhanceSingleCommand* _tmp54_;
			_tmp48_ = editing_host_page_get_photo (self);
			_tmp49_ = _tmp48_;
			_tmp50_ = enhance_single_command_new (_tmp49_);
			_tmp51_ = _tmp50_;
			_g_object_unref0 (_tmp49_);
			command = _tmp51_;
			_tmp52_ = page_get_command_manager ((Page*) self);
			_tmp53_ = _tmp52_;
			_tmp54_ = command;
			command_manager_execute (_tmp53_, (Command*) _tmp54_);
			_command_manager_unref0 (_tmp53_);
			_g_object_unref0 (command);
		}
		_tmp55_ = editing_host_page_get_photo (self);
		_tmp56_ = _tmp55_;
		photo_set_enhanced (_tmp56_, TRUE);
		_g_object_unref0 (_tmp56_);
		_g_object_unref0 (cmd);
	}
	editing_host_page_update_enhance_action (self);
	_g_object_unref0 (adjust_tool);
}

void
editing_host_page_on_copy_adjustments (EditingHostPage* self)
{
	Photo* _tmp0_;
	Photo* _tmp1_;
	PixelTransformationBundle* _tmp2_;
	PixelTransformationBundle* _tmp3_;
	g_return_if_fail (self != NULL);
	if (!editing_host_page_has_photo (self)) {
		return;
	}
	_tmp0_ = editing_host_page_get_photo (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = photo_get_color_adjustments (_tmp1_);
	_tmp3_ = _tmp2_;
	pixel_transformation_bundle_set_copied_color_adjustments (_tmp3_);
	_pixel_transformation_bundle_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	page_set_action_sensitive ((Page*) self, "PasteColorAdjustments", TRUE);
}

void
editing_host_page_on_paste_adjustments (EditingHostPage* self)
{
	PixelTransformationBundle* copied_adjustments = NULL;
	PixelTransformationBundle* _tmp0_;
	gboolean _tmp1_ = FALSE;
	AdjustColorsSingleCommand* command = NULL;
	Photo* _tmp3_;
	Photo* _tmp4_;
	PixelTransformationBundle* _tmp5_;
	AdjustColorsSingleCommand* _tmp6_;
	AdjustColorsSingleCommand* _tmp7_;
	CommandManager* _tmp8_;
	CommandManager* _tmp9_;
	AdjustColorsSingleCommand* _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp0_ = pixel_transformation_bundle_get_copied_color_adjustments ();
	copied_adjustments = _tmp0_;
	if (!editing_host_page_has_photo (self)) {
		_tmp1_ = TRUE;
	} else {
		PixelTransformationBundle* _tmp2_;
		_tmp2_ = copied_adjustments;
		_tmp1_ = _tmp2_ == NULL;
	}
	if (_tmp1_) {
		_pixel_transformation_bundle_unref0 (copied_adjustments);
		return;
	}
	_tmp3_ = editing_host_page_get_photo (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = copied_adjustments;
	_tmp6_ = adjust_colors_single_command_new (_tmp4_, _tmp5_, RESOURCES_PASTE_ADJUSTMENTS_LABEL, RESOURCES_PASTE_ADJUSTMENTS_TOOLTIP);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (_tmp4_);
	command = _tmp7_;
	_tmp8_ = page_get_command_manager ((Page*) self);
	_tmp9_ = _tmp8_;
	_tmp10_ = command;
	command_manager_execute (_tmp9_, (Command*) _tmp10_);
	_command_manager_unref0 (_tmp9_);
	_g_object_unref0 (command);
	_pixel_transformation_bundle_unref0 (copied_adjustments);
}

static void
editing_host_page_place_tool_window (EditingHostPage* self)
{
	EditingToolsEditingTool* _tmp0_;
	EditingToolsEditingToolWindow* tool_window = NULL;
	EditingToolsEditingTool* _tmp1_;
	EditingToolsEditingToolWindow* _tmp2_;
	EditingToolsEditingToolWindow* _tmp3_;
	EditingToolsEditingToolWindow* _tmp4_;
	EditingToolsEditingToolWindow* _tmp5_;
	GtkAllocation tool_alloc = {0};
	EditingToolsEditingToolWindow* _tmp6_;
	GtkAllocation _tmp7_ = {0};
	gint x = 0;
	gint y = 0;
	GeeHashMap* _tmp8_;
	EditingToolsEditingTool* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gboolean _tmp14_;
	Dimensions dimensions = {0};
	GtkWindow* _tmp63_;
	GtkWindow* _tmp64_;
	Dimensions _tmp65_ = {0};
	Dimensions _tmp66_;
	Dimensions _tmp67_;
	GtkAllocation _tmp68_;
	Dimensions _tmp69_;
	GtkAllocation _tmp70_;
	EditingToolsEditingToolWindow* _tmp71_;
	EditingToolsEditingToolWindow* _tmp72_;
	EditingToolsEditingToolWindow* _tmp73_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_tool;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->current_tool;
	_tmp2_ = editing_tools_editing_tool_get_tool_window (_tmp1_);
	tool_window = _tmp2_;
	_tmp3_ = tool_window;
	if (_tmp3_ == NULL) {
		_g_object_unref0 (tool_window);
		return;
	}
	_tmp4_ = tool_window;
	gtk_widget_show_all ((GtkWidget*) _tmp4_);
	_tmp5_ = tool_window;
	gtk_widget_hide ((GtkWidget*) _tmp5_);
	_tmp6_ = tool_window;
	gtk_widget_get_allocation ((GtkWidget*) _tmp6_, &_tmp7_);
	tool_alloc = _tmp7_;
	_tmp8_ = self->priv->last_locations;
	_tmp9_ = self->priv->current_tool;
	_tmp10_ = editing_tools_editing_tool_get_name (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_strconcat (_tmp11_, "_x", NULL);
	_tmp13_ = _tmp12_;
	_tmp14_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp8_, _tmp13_);
	_g_free0 (_tmp13_);
	if (_tmp14_) {
		GeeHashMap* _tmp15_;
		EditingToolsEditingTool* _tmp16_;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		gpointer _tmp21_;
		GeeHashMap* _tmp22_;
		EditingToolsEditingTool* _tmp23_;
		const gchar* _tmp24_;
		const gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		gpointer _tmp28_;
		_tmp15_ = self->priv->last_locations;
		_tmp16_ = self->priv->current_tool;
		_tmp17_ = editing_tools_editing_tool_get_name (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = g_strconcat (_tmp18_, "_x", NULL);
		_tmp20_ = _tmp19_;
		_tmp21_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp15_, _tmp20_);
		x = (gint) ((gintptr) _tmp21_);
		_g_free0 (_tmp20_);
		_tmp22_ = self->priv->last_locations;
		_tmp23_ = self->priv->current_tool;
		_tmp24_ = editing_tools_editing_tool_get_name (_tmp23_);
		_tmp25_ = _tmp24_;
		_tmp26_ = g_strconcat (_tmp25_, "_y", NULL);
		_tmp27_ = _tmp26_;
		_tmp28_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp22_, _tmp27_);
		y = (gint) ((gintptr) _tmp28_);
		_g_free0 (_tmp27_);
	} else {
		GtkWindow* _tmp29_;
		GtkWindow* _tmp30_;
		AppWindow* _tmp31_;
		AppWindow* _tmp32_;
		gboolean _tmp33_;
		_tmp29_ = page_get_container ((Page*) self);
		_tmp30_ = _tmp29_;
		_tmp31_ = app_window_get_instance ();
		_tmp32_ = _tmp31_;
		_tmp33_ = _tmp30_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp32_, gtk_window_get_type (), GtkWindow);
		_g_object_unref0 (_tmp32_);
		_g_object_unref0 (_tmp30_);
		if (_tmp33_) {
			gint rx = 0;
			gint ry = 0;
			GtkWindow* _tmp34_;
			GtkWindow* _tmp35_;
			GdkWindow* _tmp36_;
			gint _tmp37_ = 0;
			gint _tmp38_ = 0;
			GtkAllocation viewport_allocation = {0};
			GtkViewport* _tmp39_;
			GtkAllocation _tmp40_ = {0};
			gint cx = 0;
			gint cy = 0;
			gint cwidth = 0;
			gint cheight = 0;
			GtkAllocation _tmp41_;
			GtkAllocation _tmp42_;
			GtkAllocation _tmp43_;
			GtkAllocation _tmp44_;
			gint _tmp45_ = 0;
			GtkAllocation _tmp47_;
			_tmp34_ = page_get_container ((Page*) self);
			_tmp35_ = _tmp34_;
			_tmp36_ = gtk_widget_get_window ((GtkWidget*) _tmp35_);
			gdk_window_get_root_origin (_tmp36_, &_tmp37_, &_tmp38_);
			rx = _tmp37_;
			ry = _tmp38_;
			_g_object_unref0 (_tmp35_);
			_tmp39_ = ((SinglePhotoPage*) self)->viewport;
			gtk_widget_get_allocation ((GtkWidget*) _tmp39_, &_tmp40_);
			viewport_allocation = _tmp40_;
			_tmp41_ = viewport_allocation;
			cx = _tmp41_.x;
			_tmp42_ = viewport_allocation;
			cy = _tmp42_.y;
			_tmp43_ = viewport_allocation;
			cwidth = _tmp43_.width;
			_tmp44_ = viewport_allocation;
			cheight = _tmp44_.height;
			if (IS_DIRECT_PHOTO_PAGE (self)) {
				GtkAllocation _tmp46_;
				_tmp46_ = tool_alloc;
				_tmp45_ = ((rx + cx) + (cwidth / 2)) - (_tmp46_.width / 2);
			} else {
				_tmp45_ = (rx + cx) + (cwidth / 2);
			}
			x = _tmp45_;
			_tmp47_ = tool_alloc;
			y = ((ry + cy) + cheight) - ((_tmp47_.height / 4) * 3);
		} else {
			GtkWindow* _tmp48_;
			GtkWindow* _tmp49_;
			GtkAllocation toolbar_alloc = {0};
			GtkActionBar* _tmp50_;
			GtkActionBar* _tmp51_;
			GtkAllocation _tmp52_ = {0};
			Dimensions dimensions = {0};
			GtkWindow* _tmp53_;
			GtkWindow* _tmp54_;
			Dimensions _tmp55_ = {0};
			Dimensions _tmp56_;
			Dimensions _tmp57_;
			Dimensions _tmp58_;
			GtkAllocation _tmp59_;
			GtkAllocation _tmp60_;
			EditingToolsEditingTool* _tmp61_;
			_tmp48_ = page_get_container ((Page*) self);
			_tmp49_ = _tmp48_;
			_vala_assert (IS_FULLSCREEN_WINDOW (_tmp49_), "get_container () is FullscreenWindow");
			_g_object_unref0 (_tmp49_);
			_tmp50_ = page_get_toolbar ((Page*) self, NULL, GTK_PACK_START);
			_tmp51_ = _tmp50_;
			gtk_widget_get_allocation ((GtkWidget*) _tmp51_, &_tmp52_);
			toolbar_alloc = _tmp52_;
			_g_object_unref0 (_tmp51_);
			_tmp53_ = page_get_container ((Page*) self);
			_tmp54_ = _tmp53_;
			scaling_get_screen_dimensions (_tmp54_, &_tmp55_);
			_tmp56_ = _tmp55_;
			_g_object_unref0 (_tmp54_);
			dimensions = _tmp56_;
			_tmp57_ = dimensions;
			x = _tmp57_.width;
			_tmp58_ = dimensions;
			_tmp59_ = toolbar_alloc;
			_tmp60_ = tool_alloc;
			y = ((_tmp58_.height - _tmp59_.height) - _tmp60_.height) - EDITING_HOST_PAGE_TOOL_WINDOW_SEPARATOR;
			_tmp61_ = self->priv->current_tool;
			if (EDITING_TOOLS_IS_ADJUST_TOOL (_tmp61_)) {
				x = (x * 3) / 4;
			} else {
				GtkAllocation _tmp62_;
				_tmp62_ = tool_alloc;
				x = (x - _tmp62_.width) / 2;
			}
		}
	}
	_tmp63_ = page_get_container ((Page*) self);
	_tmp64_ = _tmp63_;
	scaling_get_screen_dimensions (_tmp64_, &_tmp65_);
	_tmp66_ = _tmp65_;
	_g_object_unref0 (_tmp64_);
	dimensions = _tmp66_;
	_tmp67_ = dimensions;
	_tmp68_ = tool_alloc;
	x = CLAMP (x, 0, _tmp67_.width - _tmp68_.width);
	_tmp69_ = dimensions;
	_tmp70_ = tool_alloc;
	y = CLAMP (y, 0, _tmp69_.height - _tmp70_.height);
	_tmp71_ = tool_window;
	gtk_window_move ((GtkWindow*) _tmp71_, x, y);
	_tmp72_ = tool_window;
	gtk_widget_show ((GtkWidget*) _tmp72_);
	_tmp73_ = tool_window;
	gtk_window_present ((GtkWindow*) _tmp73_);
	_g_object_unref0 (tool_window);
}

static void
editing_host_page_real_on_next_photo (SinglePhotoPage* base)
{
	EditingHostPage * self;
	Dimensions _tmp0_ = {0};
	Photo* current_photo = NULL;
	Photo* _tmp1_;
	Photo* _tmp2_;
	DataView* current = NULL;
	ViewCollection* _tmp3_;
	ViewCollection* _tmp4_;
	Photo* _tmp5_;
	Photo* _tmp6_;
	DataView* _tmp7_;
	DataView* _tmp8_;
	DataView* _tmp9_;
	DataView* next = NULL;
	DataView* _tmp10_;
	DataView* _tmp11_;
	self = (EditingHostPage*) base;
	dimensions_init (&_tmp0_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp0_, FALSE);
	if (!editing_host_page_has_photo (self)) {
		return;
	}
	_tmp1_ = editing_host_page_get_photo (self);
	current_photo = _tmp1_;
	_tmp2_ = current_photo;
	_vala_assert (_tmp2_ != NULL, "current_photo != null");
	_tmp3_ = page_get_view ((Page*) self);
	_tmp4_ = _tmp3_;
	_tmp5_ = editing_host_page_get_photo (self);
	_tmp6_ = _tmp5_;
	_tmp7_ = view_collection_get_view_for_source (_tmp4_, (DataSource*) _tmp6_);
	_tmp8_ = _tmp7_;
	_g_object_unref0 (_tmp6_);
	_data_collection_unref0 (_tmp4_);
	current = _tmp8_;
	_tmp9_ = current;
	if (_tmp9_ == NULL) {
		_g_object_unref0 (current);
		_g_object_unref0 (current_photo);
		return;
	}
	_tmp10_ = current;
	_tmp11_ = _g_object_ref0 (_tmp10_);
	next = _tmp11_;
	{
		gboolean _tmp12_ = FALSE;
		_tmp12_ = TRUE;
		while (TRUE) {
			ViewCollection* _tmp13_;
			ViewCollection* _tmp14_;
			DataView* _tmp15_;
			DataView* _tmp16_;
			DataView* _tmp17_;
			Photo* next_photo = NULL;
			DataView* _tmp18_;
			DataSource* _tmp19_;
			DataSource* _tmp20_;
			Photo* _tmp21_;
			Photo* _tmp22_;
			Photo* _tmp23_;
			Photo* _tmp24_;
			Photo* _tmp25_;
			if (!_tmp12_) {
			}
			_tmp12_ = FALSE;
			_tmp13_ = page_get_view ((Page*) self);
			_tmp14_ = _tmp13_;
			_tmp15_ = next;
			_tmp16_ = view_collection_get_next (_tmp14_, _tmp15_);
			_g_object_unref0 (next);
			next = _tmp16_;
			_data_collection_unref0 (_tmp14_);
			_tmp17_ = next;
			if (_tmp17_ == NULL) {
				break;
			}
			_tmp18_ = next;
			_tmp19_ = data_view_get_source (_tmp18_);
			_tmp20_ = _tmp19_;
			_tmp21_ = _g_object_ref0 (IS_PHOTO (_tmp20_) ? ((Photo*) _tmp20_) : NULL);
			next_photo = _tmp21_;
			_tmp22_ = next_photo;
			if (_tmp22_ == NULL) {
				_g_object_unref0 (next_photo);
				continue;
			}
			_tmp23_ = next_photo;
			_tmp24_ = current_photo;
			if (_tmp23_ == _tmp24_) {
				_g_object_unref0 (next_photo);
				break;
			}
			_tmp25_ = next_photo;
			editing_host_page_replace_photo (self, _tmp25_);
			_g_object_unref0 (next_photo);
			break;
		}
	}
	_g_object_unref0 (next);
	_g_object_unref0 (current);
	_g_object_unref0 (current_photo);
}

static void
editing_host_page_real_on_previous_photo (SinglePhotoPage* base)
{
	EditingHostPage * self;
	Dimensions _tmp0_ = {0};
	Photo* current_photo = NULL;
	Photo* _tmp1_;
	Photo* _tmp2_;
	DataView* current = NULL;
	ViewCollection* _tmp3_;
	ViewCollection* _tmp4_;
	Photo* _tmp5_;
	Photo* _tmp6_;
	DataView* _tmp7_;
	DataView* _tmp8_;
	DataView* _tmp9_;
	DataView* previous = NULL;
	DataView* _tmp10_;
	DataView* _tmp11_;
	self = (EditingHostPage*) base;
	dimensions_init (&_tmp0_, 0, 0);
	editing_host_page_deactivate_tool (self, NULL, NULL, &_tmp0_, FALSE);
	if (!editing_host_page_has_photo (self)) {
		return;
	}
	_tmp1_ = editing_host_page_get_photo (self);
	current_photo = _tmp1_;
	_tmp2_ = current_photo;
	_vala_assert (_tmp2_ != NULL, "current_photo != null");
	_tmp3_ = page_get_view ((Page*) self);
	_tmp4_ = _tmp3_;
	_tmp5_ = editing_host_page_get_photo (self);
	_tmp6_ = _tmp5_;
	_tmp7_ = view_collection_get_view_for_source (_tmp4_, (DataSource*) _tmp6_);
	_tmp8_ = _tmp7_;
	_g_object_unref0 (_tmp6_);
	_data_collection_unref0 (_tmp4_);
	current = _tmp8_;
	_tmp9_ = current;
	if (_tmp9_ == NULL) {
		_g_object_unref0 (current);
		_g_object_unref0 (current_photo);
		return;
	}
	_tmp10_ = current;
	_tmp11_ = _g_object_ref0 (_tmp10_);
	previous = _tmp11_;
	{
		gboolean _tmp12_ = FALSE;
		_tmp12_ = TRUE;
		while (TRUE) {
			ViewCollection* _tmp13_;
			ViewCollection* _tmp14_;
			DataView* _tmp15_;
			DataView* _tmp16_;
			DataView* _tmp17_;
			Photo* previous_photo = NULL;
			DataView* _tmp18_;
			DataSource* _tmp19_;
			DataSource* _tmp20_;
			Photo* _tmp21_;
			Photo* _tmp22_;
			Photo* _tmp23_;
			Photo* _tmp24_;
			Photo* _tmp25_;
			if (!_tmp12_) {
			}
			_tmp12_ = FALSE;
			_tmp13_ = page_get_view ((Page*) self);
			_tmp14_ = _tmp13_;
			_tmp15_ = previous;
			_tmp16_ = view_collection_get_previous (_tmp14_, _tmp15_);
			_g_object_unref0 (previous);
			previous = _tmp16_;
			_data_collection_unref0 (_tmp14_);
			_tmp17_ = previous;
			if (_tmp17_ == NULL) {
				break;
			}
			_tmp18_ = previous;
			_tmp19_ = data_view_get_source (_tmp18_);
			_tmp20_ = _tmp19_;
			_tmp21_ = _g_object_ref0 (IS_PHOTO (_tmp20_) ? ((Photo*) _tmp20_) : NULL);
			previous_photo = _tmp21_;
			_tmp22_ = previous_photo;
			if (_tmp22_ == NULL) {
				_g_object_unref0 (previous_photo);
				continue;
			}
			_tmp23_ = previous_photo;
			_tmp24_ = current_photo;
			if (_tmp23_ == _tmp24_) {
				_g_object_unref0 (previous_photo);
				break;
			}
			_tmp25_ = previous_photo;
			editing_host_page_replace_photo (self, _tmp25_);
			_g_object_unref0 (previous_photo);
			break;
		}
	}
	_g_object_unref0 (previous);
	_g_object_unref0 (current);
	_g_object_unref0 (current_photo);
}

void
editing_host_page_unset_view_collection (EditingHostPage* self)
{
	g_return_if_fail (self != NULL);
	_data_collection_unref0 (self->priv->parent_view);
	self->priv->parent_view = NULL;
}

SourceCollection*
editing_host_page_get_sources (EditingHostPage* self)
{
	SourceCollection* result;
	SourceCollection* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_sources;
	result = _tmp0_;
	return result;
}

static void
editing_host_page_set_sources (EditingHostPage* self,
                               SourceCollection* value)
{
	SourceCollection* old_value;
	g_return_if_fail (self != NULL);
	old_value = editing_host_page_get_sources (self);
	if (old_value != value) {
		SourceCollection* _tmp0_;
		_tmp0_ = _data_collection_ref0 (value);
		_data_collection_unref0 (self->priv->_sources);
		self->priv->_sources = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, editing_host_page_properties[EDITING_HOST_PAGE_SOURCES_PROPERTY]);
	}
}

static inline gpointer
editing_host_page_editing_host_canvas_get_instance_private (EditingHostPageEditingHostCanvas* self)
{
	return G_STRUCT_MEMBER_P (self, EditingHostPageEditingHostCanvas_private_offset);
}

static EditingHostPageEditingHostCanvas*
editing_host_page_editing_host_canvas_construct (GType object_type,
                                                 EditingHostPage* host_page)
{
	EditingHostPageEditingHostCanvas * self = NULL;
	GtkWindow* _tmp0_;
	GtkWindow* _tmp1_;
	GtkDrawingArea* _tmp2_;
	GdkWindow* _tmp3_;
	Photo* _tmp4_;
	Photo* _tmp5_;
	cairo_t* _tmp6_;
	cairo_t* _tmp7_;
	Dimensions _tmp8_ = {0};
	GdkPixbuf* _tmp9_;
	GdkPixbuf* _tmp10_;
	GdkRectangle _tmp11_ = {0};
	EditingHostPage* _tmp12_;
	g_return_val_if_fail (host_page != NULL, NULL);
	_tmp0_ = page_get_container ((Page*) host_page);
	_tmp1_ = _tmp0_;
	_tmp2_ = ((SinglePhotoPage*) host_page)->canvas;
	_tmp3_ = gtk_widget_get_window ((GtkWidget*) _tmp2_);
	_tmp4_ = editing_host_page_get_photo (host_page);
	_tmp5_ = _tmp4_;
	_tmp6_ = single_photo_page_get_cairo_context ((SinglePhotoPage*) host_page);
	_tmp7_ = _tmp6_;
	single_photo_page_get_surface_dim ((SinglePhotoPage*) host_page, &_tmp8_);
	_tmp9_ = single_photo_page_get_scaled_pixbuf ((SinglePhotoPage*) host_page);
	_tmp10_ = _tmp9_;
	single_photo_page_get_scaled_pixbuf_position ((SinglePhotoPage*) host_page, &_tmp11_);
	self = (EditingHostPageEditingHostCanvas*) editing_tools_photo_canvas_construct (object_type, _tmp1_, _tmp3_, _tmp5_, _tmp7_, &_tmp8_, _tmp10_, &_tmp11_);
	_g_object_unref0 (_tmp10_);
	_cairo_destroy0 (_tmp7_);
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp1_);
	_tmp12_ = _g_object_ref0 (host_page);
	_g_object_unref0 (self->priv->host_page);
	self->priv->host_page = _tmp12_;
	return self;
}

static EditingHostPageEditingHostCanvas*
editing_host_page_editing_host_canvas_new (EditingHostPage* host_page)
{
	return editing_host_page_editing_host_canvas_construct (EDITING_HOST_PAGE_TYPE_EDITING_HOST_CANVAS, host_page);
}

static void
editing_host_page_editing_host_canvas_real_repaint (EditingToolsPhotoCanvas* base)
{
	EditingHostPageEditingHostCanvas * self;
	EditingHostPage* _tmp0_;
	self = (EditingHostPageEditingHostCanvas*) base;
	_tmp0_ = self->priv->host_page;
	single_photo_page_repaint ((SinglePhotoPage*) _tmp0_, NULL);
}

static GtkStyleContext*
editing_host_page_editing_host_canvas_real_get_style_context (EditingToolsPhotoCanvas* base)
{
	EditingHostPageEditingHostCanvas * self;
	EditingHostPage* _tmp0_;
	GtkDrawingArea* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkStyleContext* result;
	self = (EditingHostPageEditingHostCanvas*) base;
	_tmp0_ = self->priv->host_page;
	_tmp1_ = ((SinglePhotoPage*) _tmp0_)->canvas;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	result = _tmp2_;
	return result;
}

static void
editing_host_page_editing_host_canvas_class_init (EditingHostPageEditingHostCanvasClass * klass,
                                                  gpointer klass_data)
{
	editing_host_page_editing_host_canvas_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &EditingHostPageEditingHostCanvas_private_offset);
	((EditingToolsPhotoCanvasClass *) klass)->repaint = (void (*) (EditingToolsPhotoCanvas*)) editing_host_page_editing_host_canvas_real_repaint;
	((EditingToolsPhotoCanvasClass *) klass)->get_style_context = (GtkStyleContext* (*) (EditingToolsPhotoCanvas*)) editing_host_page_editing_host_canvas_real_get_style_context;
	G_OBJECT_CLASS (klass)->finalize = editing_host_page_editing_host_canvas_finalize;
}

static void
editing_host_page_editing_host_canvas_instance_init (EditingHostPageEditingHostCanvas * self,
                                                     gpointer klass)
{
	self->priv = editing_host_page_editing_host_canvas_get_instance_private (self);
}

static void
editing_host_page_editing_host_canvas_finalize (GObject * obj)
{
	EditingHostPageEditingHostCanvas * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDITING_HOST_PAGE_TYPE_EDITING_HOST_CANVAS, EditingHostPageEditingHostCanvas);
	_g_object_unref0 (self->priv->host_page);
	G_OBJECT_CLASS (editing_host_page_editing_host_canvas_parent_class)->finalize (obj);
}

static GType
editing_host_page_editing_host_canvas_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingHostPageEditingHostCanvasClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_host_page_editing_host_canvas_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingHostPageEditingHostCanvas), 0, (GInstanceInitFunc) editing_host_page_editing_host_canvas_instance_init, NULL };
	GType editing_host_page_editing_host_canvas_type_id;
	editing_host_page_editing_host_canvas_type_id = g_type_register_static (EDITING_TOOLS_TYPE_PHOTO_CANVAS, "EditingHostPageEditingHostCanvas", &g_define_type_info, 0);
	EditingHostPageEditingHostCanvas_private_offset = g_type_add_instance_private (editing_host_page_editing_host_canvas_type_id, sizeof (EditingHostPageEditingHostCanvasPrivate));
	return editing_host_page_editing_host_canvas_type_id;
}

static GType
editing_host_page_editing_host_canvas_get_type (void)
{
	static volatile gsize editing_host_page_editing_host_canvas_type_id__once = 0;
	if (g_once_init_enter (&editing_host_page_editing_host_canvas_type_id__once)) {
		GType editing_host_page_editing_host_canvas_type_id;
		editing_host_page_editing_host_canvas_type_id = editing_host_page_editing_host_canvas_get_type_once ();
		g_once_init_leave (&editing_host_page_editing_host_canvas_type_id__once, editing_host_page_editing_host_canvas_type_id);
	}
	return editing_host_page_editing_host_canvas_type_id__once;
}

static void
_editing_host_page_on_viewport_resized_gtk_widget_size_allocate (GtkWidget* _sender,
                                                                 GtkAllocation* allocation,
                                                                 gpointer self)
{
	editing_host_page_on_viewport_resized ((EditingHostPage*) self);
}

static GObject *
editing_host_page_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	EditingHostPage * self;
	SourceCollection* _tmp0_;
	ViewCollection* _tmp1_;
	ViewCollection* _tmp2_;
	ViewCollection* _tmp3_;
	ViewCollection* _tmp4_;
	GtkViewport* _tmp5_;
	GtkActionBar* _tmp6_;
	parent_class = G_OBJECT_CLASS (editing_host_page_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_EDITING_HOST_PAGE, EditingHostPage);
	_tmp0_ = self->priv->_sources;
	g_signal_connect_object ((DataCollection*) _tmp0_, "items-altered", (GCallback) _editing_host_page_on_photos_altered_data_collection_items_altered, self, 0);
	_tmp1_ = page_get_view ((Page*) self);
	_tmp2_ = _tmp1_;
	g_signal_connect_object ((DataCollection*) _tmp2_, "contents-altered", (GCallback) _editing_host_page_on_view_contents_ordering_altered_data_collection_contents_altered, self, 0);
	_data_collection_unref0 (_tmp2_);
	_tmp3_ = page_get_view ((Page*) self);
	_tmp4_ = _tmp3_;
	g_signal_connect_object ((DataCollection*) _tmp4_, "ordering-changed", (GCallback) _editing_host_page_on_view_contents_ordering_altered_data_collection_ordering_changed, self, 0);
	_data_collection_unref0 (_tmp4_);
	_tmp5_ = ((SinglePhotoPage*) self)->viewport;
	g_signal_connect_object ((GtkWidget*) _tmp5_, "size-allocate", (GCallback) _editing_host_page_on_viewport_resized_gtk_widget_size_allocate, self, 0);
	_tmp6_ = page_get_toolbar ((Page*) self, NULL, GTK_PACK_START);
	_g_object_unref0 (((Page*) self)->toolbar);
	((Page*) self)->toolbar = _tmp6_;
	return obj;
}

static void
editing_host_page_class_init (EditingHostPageClass * klass,
                              gpointer klass_data)
{
	GdkDisplay* _tmp0_;
	GtkClipboard* _tmp1_;
	GtkClipboard* _tmp2_;
	editing_host_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &EditingHostPage_private_offset);
	((PageClass *) klass)->add_toolbar_widgets = (void (*) (Page*, GtkActionBar*)) editing_host_page_real_add_toolbar_widgets;
	((EditingHostPageClass *) klass)->on_zoom_assembly_key_press = (gboolean (*) (EditingHostPage*, GdkEventKey*)) editing_host_page_real_on_zoom_assembly_key_press;
	((EditingHostPageClass *) klass)->on_increase_size = (void (*) (EditingHostPage*)) editing_host_page_real_on_increase_size;
	((EditingHostPageClass *) klass)->on_decrease_size = (void (*) (EditingHostPage*)) editing_host_page_real_on_decrease_size;
	((SinglePhotoPageClass *) klass)->save_zoom_state = (void (*) (SinglePhotoPage*)) editing_host_page_real_save_zoom_state;
	((SinglePhotoPageClass *) klass)->get_zoom_buffer = (ZoomBuffer* (*) (SinglePhotoPage*)) editing_host_page_real_get_zoom_buffer;
	((PageClass *) klass)->on_mousewheel_up = (gboolean (*) (Page*, GdkEventScroll*)) editing_host_page_real_on_mousewheel_up;
	((PageClass *) klass)->on_mousewheel_down = (gboolean (*) (Page*, GdkEventScroll*)) editing_host_page_real_on_mousewheel_down;
	((SinglePhotoPageClass *) klass)->restore_zoom_state = (void (*) (SinglePhotoPage*)) editing_host_page_real_restore_zoom_state;
	((SinglePhotoPageClass *) klass)->is_zoom_supported = (gboolean (*) (SinglePhotoPage*)) editing_host_page_real_is_zoom_supported;
	((PageClass *) klass)->set_container = (void (*) (Page*, GtkWindow*)) editing_host_page_real_set_container;
	((EditingHostPageClass *) klass)->photo_changing = (void (*) (EditingHostPage*, Photo*)) editing_host_page_real_photo_changing;
	((GtkWidgetClass *) klass)->realize = (void (*) (GtkWidget*)) editing_host_page_real_realize;
	((PageClass *) klass)->switched_to = (void (*) (Page*)) editing_host_page_real_switched_to;
	((PageClass *) klass)->switching_from = (void (*) (Page*)) editing_host_page_real_switching_from;
	((PageClass *) klass)->switching_to_fullscreen = (void (*) (Page*, FullscreenWindow*)) editing_host_page_real_switching_to_fullscreen;
	((PageClass *) klass)->returning_from_fullscreen = (void (*) (Page*, FullscreenWindow*)) editing_host_page_real_returning_from_fullscreen;
	((EditingHostPageClass *) klass)->create_photo_view = (DataView* (*) (EditingHostPage*, DataSource*)) editing_host_page_real_create_photo_view;
	((EditingHostPageClass *) klass)->update_ui = (void (*) (EditingHostPage*, gboolean)) editing_host_page_real_update_ui;
	((EditingHostPageClass *) klass)->notify_photo_backing_missing = (void (*) (EditingHostPage*, Photo*, gboolean)) editing_host_page_real_notify_photo_backing_missing;
	((EditingHostPageClass *) klass)->confirm_replace_photo = (gboolean (*) (EditingHostPage*, Photo*, Photo*)) editing_host_page_real_confirm_replace_photo;
	((SinglePhotoPageClass *) klass)->cancel_zoom = (void (*) (SinglePhotoPage*)) editing_host_page_real_cancel_zoom;
	((PageClass *) klass)->on_resize_finished = (void (*) (Page*, GdkRectangle*)) editing_host_page_real_on_resize_finished;
	((PageClass *) klass)->update_actions = (void (*) (Page*, gint, gint)) editing_host_page_real_update_actions;
	((PageClass *) klass)->on_shift_pressed = (gboolean (*) (Page*, GdkEventKey*)) editing_host_page_real_on_shift_pressed;
	((PageClass *) klass)->on_shift_released = (gboolean (*) (Page*, GdkEventKey*)) editing_host_page_real_on_shift_released;
	((PageClass *) klass)->on_alt_pressed = (gboolean (*) (Page*, GdkEventKey*)) editing_host_page_real_on_alt_pressed;
	((PageClass *) klass)->on_alt_released = (gboolean (*) (Page*, GdkEventKey*)) editing_host_page_real_on_alt_released;
	((EditingHostPageClass *) klass)->on_double_click = (gboolean (*) (EditingHostPage*, GdkEventButton*)) editing_host_page_real_on_double_click;
	((PageClass *) klass)->on_left_click = (gboolean (*) (Page*, GdkEventButton*)) editing_host_page_real_on_left_click;
	((PageClass *) klass)->on_left_released = (gboolean (*) (Page*, GdkEventButton*)) editing_host_page_real_on_left_released;
	((PageClass *) klass)->on_right_click = (gboolean (*) (Page*, GdkEventButton*)) editing_host_page_real_on_right_click;
	((PageClass *) klass)->on_motion = (gboolean (*) (Page*, GdkEventMotion*, gint, gint, GdkModifierType)) editing_host_page_real_on_motion;
	((PageClass *) klass)->on_leave_notify_event = (gboolean (*) (Page*)) editing_host_page_real_on_leave_notify_event;
	((PageClass *) klass)->on_move_finished = (void (*) (Page*, GdkRectangle*)) editing_host_page_real_on_move_finished;
	((GtkWidgetClass *) klass)->key_press_event = (gboolean (*) (GtkWidget*, GdkEventKey*)) editing_host_page_real_key_press_event;
	((SinglePhotoPageClass *) klass)->new_surface = (void (*) (SinglePhotoPage*, cairo_t*, Dimensions*)) editing_host_page_real_new_surface;
	((SinglePhotoPageClass *) klass)->updated_pixbuf = (void (*) (SinglePhotoPage*, GdkPixbuf*, SinglePhotoPageUpdateReason, Dimensions*)) editing_host_page_real_updated_pixbuf;
	((EditingHostPageClass *) klass)->get_bottom_left_trinket = (GdkPixbuf* (*) (EditingHostPage*, gint)) editing_host_page_real_get_bottom_left_trinket;
	((EditingHostPageClass *) klass)->get_top_left_trinket = (GdkPixbuf* (*) (EditingHostPage*, gint)) editing_host_page_real_get_top_left_trinket;
	((EditingHostPageClass *) klass)->get_top_right_trinket = (GdkPixbuf* (*) (EditingHostPage*, gint)) editing_host_page_real_get_top_right_trinket;
	((EditingHostPageClass *) klass)->get_bottom_right_trinket = (GdkPixbuf* (*) (EditingHostPage*, gint)) editing_host_page_real_get_bottom_right_trinket;
	((SinglePhotoPageClass *) klass)->paint = (void (*) (SinglePhotoPage*, cairo_t*, Dimensions*)) editing_host_page_real_paint;
	((PageClass *) klass)->on_ctrl_pressed = (gboolean (*) (Page*, GdkEventKey*)) editing_host_page_real_on_ctrl_pressed;
	((PageClass *) klass)->on_ctrl_released = (gboolean (*) (Page*, GdkEventKey*)) editing_host_page_real_on_ctrl_released;
	((SinglePhotoPageClass *) klass)->on_next_photo = (void (*) (SinglePhotoPage*)) editing_host_page_real_on_next_photo;
	((SinglePhotoPageClass *) klass)->on_previous_photo = (void (*) (SinglePhotoPage*)) editing_host_page_real_on_previous_photo;
	G_OBJECT_CLASS (klass)->get_property = _vala_editing_host_page_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_editing_host_page_set_property;
	G_OBJECT_CLASS (klass)->constructor = editing_host_page_constructor;
	G_OBJECT_CLASS (klass)->finalize = editing_host_page_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), EDITING_HOST_PAGE_SOURCES_PROPERTY, editing_host_page_properties[EDITING_HOST_PAGE_SOURCES_PROPERTY] = param_spec_data_collection ("sources", "sources", "sources", TYPE_SOURCE_COLLECTION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	_tmp0_ = gdk_display_get_default ();
	_tmp1_ = gtk_clipboard_get_for_display (_tmp0_, GDK_SELECTION_CLIPBOARD);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (editing_host_page_clipboard);
	editing_host_page_clipboard = _tmp2_;
}

static void
editing_host_page_instance_init (EditingHostPage * self,
                                 gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = editing_host_page_get_instance_private (self);
	self->priv->parent_view = NULL;
	self->priv->swapped = NULL;
	self->priv->pixbuf_dirty = TRUE;
	self->rotate_button = NULL;
	self->priv->flip_button = NULL;
	self->priv->crop_button = NULL;
	self->priv->redeye_button = NULL;
	self->priv->adjust_button = NULL;
	self->priv->straighten_button = NULL;
	self->enhance_button = NULL;
	self->priv->zoom_assembly = NULL;
	self->priv->prev_button = NULL;
	self->priv->next_button = NULL;
	self->priv->current_tool = NULL;
	self->priv->current_editing_toggle = NULL;
	self->priv->cancel_editing_pixbuf = NULL;
	self->priv->photo_missing = FALSE;
	self->priv->cache = NULL;
	self->priv->master_cache = NULL;
	self->priv->dnd_handler = NULL;
	self->priv->is_pan_in_progress = FALSE;
	self->priv->saved_slider_val = 0.0;
	self->priv->zoom_buffer = NULL;
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_INT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->last_locations = _tmp0_;
	self->priv->zooming = FALSE;
}

static void
editing_host_page_finalize (GObject * obj)
{
	EditingHostPage * self;
	SourceCollection* _tmp0_;
	guint _tmp1_;
	ViewCollection* _tmp2_;
	ViewCollection* _tmp3_;
	guint _tmp4_;
	ViewCollection* _tmp5_;
	ViewCollection* _tmp6_;
	guint _tmp7_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_EDITING_HOST_PAGE, EditingHostPage);
	_tmp0_ = self->priv->_sources;
	g_signal_parse_name ("items-altered", TYPE_DATA_COLLECTION, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((DataCollection*) _tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _editing_host_page_on_photos_altered_data_collection_items_altered, self);
	_tmp2_ = page_get_view ((Page*) self);
	_tmp3_ = _tmp2_;
	g_signal_parse_name ("contents-altered", TYPE_DATA_COLLECTION, &_tmp4_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((DataCollection*) _tmp3_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _editing_host_page_on_view_contents_ordering_altered_data_collection_contents_altered, self);
	_data_collection_unref0 (_tmp3_);
	_tmp5_ = page_get_view ((Page*) self);
	_tmp6_ = _tmp5_;
	g_signal_parse_name ("ordering-changed", TYPE_DATA_COLLECTION, &_tmp7_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((DataCollection*) _tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _editing_host_page_on_view_contents_ordering_altered_data_collection_ordering_changed, self);
	_data_collection_unref0 (_tmp6_);
	_data_collection_unref0 (self->priv->parent_view);
	_g_object_unref0 (self->priv->swapped);
	_g_object_unref0 (self->rotate_button);
	_g_object_unref0 (self->priv->flip_button);
	_g_object_unref0 (self->priv->crop_button);
	_g_object_unref0 (self->priv->redeye_button);
	_g_object_unref0 (self->priv->adjust_button);
	_g_object_unref0 (self->priv->straighten_button);
	_g_object_unref0 (self->enhance_button);
	_g_object_unref0 (self->priv->zoom_assembly);
	_g_object_unref0 (self->priv->prev_button);
	_g_object_unref0 (self->priv->next_button);
	_g_object_unref0 (self->priv->current_tool);
	_g_object_unref0 (self->priv->current_editing_toggle);
	_g_object_unref0 (self->priv->cancel_editing_pixbuf);
	_g_object_unref0 (self->priv->cache);
	_g_object_unref0 (self->priv->master_cache);
	_drag_and_drop_handler_unref0 (self->priv->dnd_handler);
	_g_object_unref0 (self->priv->zoom_buffer);
	_g_object_unref0 (self->priv->last_locations);
	_data_collection_unref0 (self->priv->_sources);
	G_OBJECT_CLASS (editing_host_page_parent_class)->finalize (obj);
}

static GType
editing_host_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EditingHostPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) editing_host_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EditingHostPage), 0, (GInstanceInitFunc) editing_host_page_instance_init, NULL };
	GType editing_host_page_type_id;
	editing_host_page_type_id = g_type_register_static (TYPE_SINGLE_PHOTO_PAGE, "EditingHostPage", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	EditingHostPage_private_offset = g_type_add_instance_private (editing_host_page_type_id, sizeof (EditingHostPagePrivate));
	return editing_host_page_type_id;
}

GType
editing_host_page_get_type (void)
{
	static volatile gsize editing_host_page_type_id__once = 0;
	if (g_once_init_enter (&editing_host_page_type_id__once)) {
		GType editing_host_page_type_id;
		editing_host_page_type_id = editing_host_page_get_type_once ();
		g_once_init_leave (&editing_host_page_type_id__once, editing_host_page_type_id);
	}
	return editing_host_page_type_id__once;
}

static void
_vala_editing_host_page_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	EditingHostPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_EDITING_HOST_PAGE, EditingHostPage);
	switch (property_id) {
		case EDITING_HOST_PAGE_SOURCES_PROPERTY:
		value_set_data_collection (value, editing_host_page_get_sources (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_editing_host_page_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	EditingHostPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_EDITING_HOST_PAGE, EditingHostPage);
	switch (property_id) {
		case EDITING_HOST_PAGE_SOURCES_PROPERTY:
		editing_host_page_set_sources (self, value_get_data_collection (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

