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

/*
Copyright (C) 2012 2013 2014 Johan Mattsson

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/

#include <gtk/gtk.h>
#include <birdfont.h>
#include <glib-object.h>
#include <webkit2/webkit2.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <libnotify/notify.h>
#include <gdk/gdk.h>
#include <cairo-gobject.h>
#include <gio/gio.h>
#include <stdio.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib/gstdio.h>
#include <float.h>
#include <math.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define BIRD_FONT_TYPE_GTK_WINDOW (bird_font_gtk_window_get_type ())
#define BIRD_FONT_GTK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_GTK_WINDOW, BirdFontGtkWindow))
#define BIRD_FONT_GTK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_GTK_WINDOW, BirdFontGtkWindowClass))
#define BIRD_FONT_IS_GTK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_GTK_WINDOW))
#define BIRD_FONT_IS_GTK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_GTK_WINDOW))
#define BIRD_FONT_GTK_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_GTK_WINDOW, BirdFontGtkWindowClass))

typedef struct _BirdFontGtkWindow BirdFontGtkWindow;
typedef struct _BirdFontGtkWindowClass BirdFontGtkWindowClass;
typedef struct _BirdFontGtkWindowPrivate BirdFontGtkWindowPrivate;

#define BIRD_FONT_TYPE_GLYPH_CANVAS_AREA (bird_font_glyph_canvas_area_get_type ())
#define BIRD_FONT_GLYPH_CANVAS_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_GLYPH_CANVAS_AREA, BirdFontGlyphCanvasArea))
#define BIRD_FONT_GLYPH_CANVAS_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_GLYPH_CANVAS_AREA, BirdFontGlyphCanvasAreaClass))
#define BIRD_FONT_IS_GLYPH_CANVAS_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_GLYPH_CANVAS_AREA))
#define BIRD_FONT_IS_GLYPH_CANVAS_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_GLYPH_CANVAS_AREA))
#define BIRD_FONT_GLYPH_CANVAS_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_GLYPH_CANVAS_AREA, BirdFontGlyphCanvasAreaClass))

typedef struct _BirdFontGlyphCanvasArea BirdFontGlyphCanvasArea;
typedef struct _BirdFontGlyphCanvasAreaClass BirdFontGlyphCanvasAreaClass;

#define BIRD_FONT_TYPE_TOOLBOX_CANVAS (bird_font_toolbox_canvas_get_type ())
#define BIRD_FONT_TOOLBOX_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_TOOLBOX_CANVAS, BirdFontToolboxCanvas))
#define BIRD_FONT_TOOLBOX_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_TOOLBOX_CANVAS, BirdFontToolboxCanvasClass))
#define BIRD_FONT_IS_TOOLBOX_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_TOOLBOX_CANVAS))
#define BIRD_FONT_IS_TOOLBOX_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_TOOLBOX_CANVAS))
#define BIRD_FONT_TOOLBOX_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_TOOLBOX_CANVAS, BirdFontToolboxCanvasClass))

typedef struct _BirdFontToolboxCanvas BirdFontToolboxCanvas;
typedef struct _BirdFontToolboxCanvasClass BirdFontToolboxCanvasClass;
enum  {
	BIRD_FONT_GTK_WINDOW_0_PROPERTY,
	BIRD_FONT_GTK_WINDOW_NUM_PROPERTIES
};
static GParamSpec* bird_font_gtk_window_properties[BIRD_FONT_GTK_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define BIRD_FONT_TYPE_TABBAR_CANVAS (bird_font_tabbar_canvas_get_type ())
#define BIRD_FONT_TABBAR_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_TABBAR_CANVAS, BirdFontTabbarCanvas))
#define BIRD_FONT_TABBAR_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_TABBAR_CANVAS, BirdFontTabbarCanvasClass))
#define BIRD_FONT_IS_TABBAR_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_TABBAR_CANVAS))
#define BIRD_FONT_IS_TABBAR_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_TABBAR_CANVAS))
#define BIRD_FONT_TABBAR_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_TABBAR_CANVAS, BirdFontTabbarCanvasClass))

typedef struct _BirdFontTabbarCanvas BirdFontTabbarCanvas;
typedef struct _BirdFontTabbarCanvasClass BirdFontTabbarCanvasClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __vala_GtkSelectionData_free0(var) ((var == NULL) ? NULL : (var = (_vala_GtkSelectionData_free (var), NULL)))
#define _g_thread_unref0(var) ((var == NULL) ? NULL : (var = (g_thread_unref (var), NULL)))
#define _g_source_unref0(var) ((var == NULL) ? NULL : (var = (g_source_unref (var), NULL)))
typedef struct _BirdFontTabbarCanvasPrivate BirdFontTabbarCanvasPrivate;
enum  {
	BIRD_FONT_TABBAR_CANVAS_0_PROPERTY,
	BIRD_FONT_TABBAR_CANVAS_NUM_PROPERTIES
};
static GParamSpec* bird_font_tabbar_canvas_properties[BIRD_FONT_TABBAR_CANVAS_NUM_PROPERTIES];
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
typedef struct _BirdFontToolboxCanvasPrivate BirdFontToolboxCanvasPrivate;
enum  {
	BIRD_FONT_TOOLBOX_CANVAS_0_PROPERTY,
	BIRD_FONT_TOOLBOX_CANVAS_NUM_PROPERTIES
};
static GParamSpec* bird_font_toolbox_canvas_properties[BIRD_FONT_TOOLBOX_CANVAS_NUM_PROPERTIES];
typedef struct _BirdFontGlyphCanvasAreaPrivate BirdFontGlyphCanvasAreaPrivate;
enum  {
	BIRD_FONT_GLYPH_CANVAS_AREA_0_PROPERTY,
	BIRD_FONT_GLYPH_CANVAS_AREA_NUM_PROPERTIES
};
static GParamSpec* bird_font_glyph_canvas_area_properties[BIRD_FONT_GLYPH_CANVAS_AREA_NUM_PROPERTIES];
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))

struct _BirdFontGtkWindow {
	GtkWindow parent_instance;
	BirdFontGtkWindowPrivate * priv;
};

struct _BirdFontGtkWindowClass {
	GtkWindowClass parent_class;
};

struct _BirdFontGtkWindowPrivate {
	GtkBox* list_box;
	GtkBox* canvas_box;
	WebKitWebView* html_canvas;
	GtkScrolledWindow* html_box;
	GtkBox* tab_box;
	BirdFontGlyphCanvasArea* glyph_canvas_area;
	GtkClipboard* clipboard;
	gchar* clipboard_svg;
	gchar* inkscape_clipboard;
	BirdFontToolboxCanvas* toolbox;
	BirdFontTask* background_task;
};

struct _BirdFontTabbarCanvas {
	GtkDrawingArea parent_instance;
	BirdFontTabbarCanvasPrivate * priv;
};

struct _BirdFontTabbarCanvasClass {
	GtkDrawingAreaClass parent_class;
};

struct _BirdFontTabbarCanvasPrivate {
	BirdFontTabBar* tabbar;
};

struct _BirdFontToolboxCanvas {
	GtkDrawingArea parent_instance;
	BirdFontToolboxCanvasPrivate * priv;
};

struct _BirdFontToolboxCanvasClass {
	GtkDrawingAreaClass parent_class;
};

struct _BirdFontToolboxCanvasPrivate {
	BirdFontToolbox* tb;
};

struct _BirdFontGlyphCanvasArea {
	GtkDrawingArea parent_instance;
	BirdFontGlyphCanvasAreaPrivate * priv;
};

struct _BirdFontGlyphCanvasAreaClass {
	GtkDrawingAreaClass parent_class;
};

struct _BirdFontGlyphCanvasAreaPrivate {
	BirdFontGlyphCanvas* glyph_canvas;
	BirdFontWidgetAllocation* alloc;
	guint32 last_release;
	guint32 last_press;
};

static gint BirdFontGtkWindow_private_offset;
static gpointer bird_font_gtk_window_parent_class = NULL;
static BirdFontNativeWindowIface * bird_font_gtk_window_bird_font_native_window_parent_iface = NULL;
static gint BirdFontTabbarCanvas_private_offset;
static gpointer bird_font_tabbar_canvas_parent_class = NULL;
static gint BirdFontToolboxCanvas_private_offset;
static gpointer bird_font_toolbox_canvas_parent_class = NULL;
static gint BirdFontGlyphCanvasArea_private_offset;
static gpointer bird_font_glyph_canvas_area_parent_class = NULL;

VALA_EXTERN GType bird_font_gtk_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BirdFontGtkWindow, g_object_unref)
VALA_EXTERN GType bird_font_glyph_canvas_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BirdFontGlyphCanvasArea, g_object_unref)
VALA_EXTERN GType bird_font_toolbox_canvas_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BirdFontToolboxCanvas, g_object_unref)
VALA_EXTERN void bird_font_gtk_window_idle (void);
static void _bird_font_gtk_window_idle_bird_font_task_runnable (gpointer self);
VALA_EXTERN BirdFontGtkWindow* bird_font_gtk_window_new (const gchar* title);
VALA_EXTERN BirdFontGtkWindow* bird_font_gtk_window_construct (GType object_type,
                                                   const gchar* title);
VALA_EXTERN void bird_font_gtk_window_init (BirdFontGtkWindow* self);
VALA_EXTERN void bird_font_gtk_window_window_focus (BirdFontGtkWindow* self,
                                        void* data);
static gboolean __lambda18_ (BirdFontGtkWindow* self);
static gboolean ___lambda18__gtk_widget_delete_event (GtkWidget* _sender,
                                               GdkEventAny* event,
                                               gpointer self);
static void bird_font_gtk_window_set_size_and_position (BirdFontGtkWindow* self);
VALA_EXTERN BirdFontGlyphCanvasArea* bird_font_glyph_canvas_area_new (BirdFontGlyphCanvas* gc);
VALA_EXTERN BirdFontGlyphCanvasArea* bird_font_glyph_canvas_area_construct (GType object_type,
                                                                BirdFontGlyphCanvas* gc);
static void __lambda19_ (BirdFontGtkWindow* self,
                  BirdFontTabBar* f,
                  BirdFontTab* tab);
static void ___lambda19__bird_font_tab_bar_signal_tab_selected (BirdFontTabBar* _sender,
                                                         BirdFontTab* selected_tab,
                                                         gpointer self);
static gboolean __lambda20_ (BirdFontGtkWindow* self,
                      GtkWidget* t,
                      cairo_t* e);
static gboolean ___lambda20__gtk_widget_draw (GtkWidget* _sender,
                                       cairo_t* cr,
                                       gpointer self);
VALA_EXTERN BirdFontTabbarCanvas* bird_font_tabbar_canvas_new (BirdFontTabBar* tb);
VALA_EXTERN BirdFontTabbarCanvas* bird_font_tabbar_canvas_construct (GType object_type,
                                                         BirdFontTabBar* tb);
VALA_EXTERN GType bird_font_tabbar_canvas_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BirdFontTabbarCanvas, g_object_unref)
VALA_EXTERN BirdFontToolboxCanvas* bird_font_toolbox_canvas_new (BirdFontToolbox* toolbox);
VALA_EXTERN BirdFontToolboxCanvas* bird_font_toolbox_canvas_construct (GType object_type,
                                                           BirdFontToolbox* toolbox);
static gboolean __lambda26_ (BirdFontGtkWindow* self,
                      GtkWidget* t,
                      GdkEventKey* event);
static gboolean ___lambda26__gtk_widget_key_press_event (GtkWidget* _sender,
                                                  GdkEventKey* event,
                                                  gpointer self);
static gboolean __lambda27_ (BirdFontGtkWindow* self,
                      GtkWidget* t,
                      GdkEventKey* event);
static gboolean ___lambda27__gtk_widget_key_release_event (GtkWidget* _sender,
                                                    GdkEventKey* event,
                                                    gpointer self);
static void __lambda28_ (BirdFontGtkWindow* self);
static void ___lambda28__gtk_widget_size_allocate (GtkWidget* _sender,
                                            GtkAllocation* allocation,
                                            gpointer self);
VALA_EXTERN void bird_font_gtk_window_reset_modifier (GdkModifierType flags);
static void bird_font_gtk_window_real_font_loaded (BirdFontNativeWindow* base);
VALA_EXTERN void bird_font_gtk_window_dump_clipboard_content (BirdFontGtkWindow* self,
                                                  GtkClipboard* clipboard,
                                                  GtkSelectionData* selection_data);
VALA_EXTERN void bird_font_gtk_window_dump_clipboard_target (BirdFontGtkWindow* self,
                                                 GtkClipboard* clipboard,
                                                 GdkAtom* atoms,
                                                 gint atoms_length1);
static void _bird_font_gtk_window_dump_clipboard_content_gtk_clipboard_received_func (GtkClipboard* clipboard,
                                                                               GtkSelectionData* selection_data,
                                                                               gpointer self);
VALA_EXTERN void bird_font_gtk_window_dump_clipboard (BirdFontGtkWindow* self);
static void _bird_font_gtk_window_dump_clipboard_target_gtk_clipboard_targets_received_func (GtkClipboard* clipboard,
                                                                                      GdkAtom* atoms,
                                                                                      gint n_atoms,
                                                                                      gpointer self);
static gchar* bird_font_gtk_window_real_get_clipboard_data (BirdFontNativeWindow* base);
static void _vala_GtkSelectionData_free (GtkSelectionData* self);
static void bird_font_gtk_window_real_set_inkscape_clipboard (BirdFontNativeWindow* base,
                                                       const gchar* inkscape_clipboard_data);
static void ___lambda29_ (GtkClipboard* clipboard,
                   GtkSelectionData* selection_data,
                   guint info,
                   void* owner);
static void ____lambda29__gtk_clipboard_get_func (GtkClipboard* clipboard,
                                           GtkSelectionData* selection_data,
                                           guint info,
                                           void* user_data_or_owner);
static void ___lambda30_ (GtkClipboard* clipboard,
                   void* user_data);
static void ____lambda30__gtk_clipboard_clear_func (GtkClipboard* clipboard,
                                             void* user_data_or_owner);
static void bird_font_gtk_window_real_set_clipboard_text (BirdFontNativeWindow* base,
                                                   const gchar* text);
static gchar* bird_font_gtk_window_real_get_clipboard_text (BirdFontNativeWindow* base);
static void bird_font_gtk_window_real_set_clipboard (BirdFontNativeWindow* base,
                                              const gchar* svg);
static void __lambda31_ (GtkClipboard* clipboard,
                  GtkSelectionData* selection_data,
                  guint info,
                  void* owner);
static void ___lambda31__gtk_clipboard_get_func (GtkClipboard* clipboard,
                                          GtkSelectionData* selection_data,
                                          guint info,
                                          void* user_data_or_owner);
static void __lambda32_ (GtkClipboard* clipboard,
                  void* user_data);
static void ___lambda32__gtk_clipboard_clear_func (GtkClipboard* clipboard,
                                            void* user_data_or_owner);
static void bird_font_gtk_window_real_update_window_size (BirdFontNativeWindow* base);
static void bird_font_gtk_window_real_quit (BirdFontNativeWindow* base);
static void bird_font_gtk_window_real_file_chooser (BirdFontNativeWindow* base,
                                             const gchar* title,
                                             BirdFontFileChooser* fc,
                                             guint flags);
VALA_EXTERN gchar* bird_font_gtk_window_show_file_chooser (BirdFontGtkWindow* self,
                                               const gchar* title,
                                               GtkFileChooserAction action,
                                               const gchar* label);
static gboolean bird_font_gtk_window_real_convert_to_png (BirdFontNativeWindow* base,
                                                   const gchar* from,
                                                   const gchar* to);
static void bird_font_gtk_window_real_run_background_thread (BirdFontNativeWindow* base,
                                                      BirdFontTask* t);
VALA_EXTERN void* bird_font_gtk_window_background_thread (BirdFontGtkWindow* self);
static gpointer _bird_font_gtk_window_background_thread_gthread_func (gpointer self);
static void bird_font_gtk_window_real_run_non_blocking_background_thread (BirdFontNativeWindow* base,
                                                                   BirdFontTask* t);
static gpointer _bird_font_task_perform_task_gthread_func (gpointer self);
static void bird_font_gtk_window_real_export_font (BirdFontNativeWindow* base);
VALA_EXTERN void* bird_font_gtk_window_export_thread (BirdFontGtkWindow* self);
static gpointer _bird_font_gtk_window_export_thread_gthread_func (gpointer self);
static gboolean __lambda33_ (BirdFontGtkWindow* self);
static gboolean ___lambda33__gsource_func (gpointer self);
static void bird_font_gtk_window_real_load (BirdFontNativeWindow* base);
VALA_EXTERN void* bird_font_gtk_window_loading_thread (BirdFontGtkWindow* self);
static gpointer _bird_font_gtk_window_loading_thread_gthread_func (gpointer self);
static void bird_font_gtk_window_real_save (BirdFontNativeWindow* base);
VALA_EXTERN void* bird_font_gtk_window_saving_thread (BirdFontGtkWindow* self);
static gpointer _bird_font_gtk_window_saving_thread_gthread_func (gpointer self);
static void bird_font_gtk_window_real_load_background_image (BirdFontNativeWindow* base);
VALA_EXTERN void* bird_font_gtk_window_background_image_thread (BirdFontGtkWindow* self);
static gpointer _bird_font_gtk_window_background_image_thread_gthread_func (gpointer self);
static gboolean bird_font_gtk_window_real_can_export (BirdFontNativeWindow* base);
static void bird_font_gtk_window_real_set_cursor (BirdFontNativeWindow* base,
                                           gint visible);
static gdouble bird_font_gtk_window_real_get_screen_scale (BirdFontNativeWindow* base);
static void bird_font_gtk_window_finalize (GObject * obj);
static GType bird_font_gtk_window_get_type_once (void);
static gboolean __lambda21_ (BirdFontTabbarCanvas* self,
                      GtkWidget* t,
                      GdkEventMotion* e);
static gboolean ___lambda21__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                                      GdkEventMotion* event,
                                                      gpointer self);
static gboolean __lambda22_ (BirdFontTabbarCanvas* self,
                      GtkWidget* t,
                      GdkEventButton* e);
static gboolean ___lambda22__gtk_widget_button_press_event (GtkWidget* _sender,
                                                     GdkEventButton* event,
                                                     gpointer self);
static gboolean __lambda23_ (BirdFontTabbarCanvas* self,
                      GtkWidget* t,
                      cairo_t* e);
static gboolean ___lambda23__gtk_widget_draw (GtkWidget* _sender,
                                       cairo_t* cr,
                                       gpointer self);
static void __lambda24_ (BirdFontTabbarCanvas* self,
                  BirdFontTab* t);
static void ___lambda24__bird_font_tab_bar_signal_tab_selected (BirdFontTabBar* _sender,
                                                         BirdFontTab* selected_tab,
                                                         gpointer self);
static void __lambda25_ (BirdFontTabbarCanvas* self,
                  gint x,
                  gint y,
                  gint w,
                  gint h);
static void ___lambda25__bird_font_tab_bar_redraw_tab_bar (BirdFontTabBar* _sender,
                                                    gint x,
                                                    gint y,
                                                    gint w,
                                                    gint h,
                                                    gpointer self);
static void bird_font_tabbar_canvas_finalize (GObject * obj);
static GType bird_font_tabbar_canvas_get_type_once (void);
static void __lambda10_ (BirdFontToolboxCanvas* self);
static void ___lambda10__gtk_widget_realize (GtkWidget* _sender,
                                      gpointer self);
static void __lambda11_ (BirdFontToolboxCanvas* self,
                  gint x,
                  gint y,
                  gint w,
                  gint h);
static void ___lambda11__bird_font_toolbox_redraw (BirdFontToolbox* _sender,
                                            gint x,
                                            gint y,
                                            gint w,
                                            gint h,
                                            gpointer self);
static gboolean __lambda12_ (BirdFontToolboxCanvas* self,
                      GtkWidget* se,
                      GdkEventButton* e);
static gboolean ___lambda12__gtk_widget_button_press_event (GtkWidget* _sender,
                                                     GdkEventButton* event,
                                                     gpointer self);
static gboolean __lambda13_ (BirdFontToolboxCanvas* self,
                      GtkWidget* se,
                      GdkEventButton* e);
static gboolean ___lambda13__gtk_widget_button_release_event (GtkWidget* _sender,
                                                       GdkEventButton* event,
                                                       gpointer self);
static gboolean __lambda14_ (BirdFontToolboxCanvas* self,
                      GtkWidget* sen,
                      GdkEventMotion* e);
static gboolean ___lambda14__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                                      GdkEventMotion* event,
                                                      gpointer self);
static gboolean __lambda15_ (BirdFontToolboxCanvas* self,
                      GtkWidget* t,
                      cairo_t* e);
static gboolean ___lambda15__gtk_widget_draw (GtkWidget* _sender,
                                       cairo_t* cr,
                                       gpointer self);
static gboolean __lambda16_ (BirdFontToolboxCanvas* self,
                      GtkWidget* t,
                      GdkEventScroll* e);
static gboolean ___lambda16__gtk_widget_scroll_event (GtkWidget* _sender,
                                               GdkEventScroll* event,
                                               gpointer self);
static gboolean __lambda17_ (BirdFontToolboxCanvas* self,
                      GtkWidget* t,
                      GdkEventCrossing* e);
static gboolean ___lambda17__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                                     GdkEventCrossing* event,
                                                     gpointer self);
static void bird_font_toolbox_canvas_finalize (GObject * obj);
static GType bird_font_toolbox_canvas_get_type_once (void);
static void __lambda4_ (BirdFontGlyphCanvasArea* self,
                 gint x,
                 gint y,
                 gint w,
                 gint h);
static void ___lambda4__bird_font_glyph_canvas_signal_redraw_area (BirdFontGlyphCanvas* _sender,
                                                            gint x,
                                                            gint y,
                                                            gint w,
                                                            gint h,
                                                            gpointer self);
static gboolean __lambda5_ (BirdFontGlyphCanvasArea* self,
                     GtkWidget* t,
                     cairo_t* e);
static gboolean ___lambda5__gtk_widget_draw (GtkWidget* _sender,
                                      cairo_t* cr,
                                      gpointer self);
static gboolean __lambda6_ (BirdFontGlyphCanvasArea* self,
                     GtkWidget* t,
                     GdkEventButton* e);
static gboolean ___lambda6__gtk_widget_button_press_event (GtkWidget* _sender,
                                                    GdkEventButton* event,
                                                    gpointer self);
static gboolean __lambda7_ (BirdFontGlyphCanvasArea* self,
                     GtkWidget* t,
                     GdkEventButton* e);
static gboolean ___lambda7__gtk_widget_button_release_event (GtkWidget* _sender,
                                                      GdkEventButton* event,
                                                      gpointer self);
static gboolean __lambda8_ (BirdFontGlyphCanvasArea* self,
                     GtkWidget* t,
                     GdkEventMotion* e);
static gboolean ___lambda8__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                                     GdkEventMotion* event,
                                                     gpointer self);
static gboolean __lambda9_ (BirdFontGlyphCanvasArea* self,
                     GtkWidget* t,
                     GdkEventScroll* e);
static gboolean ___lambda9__gtk_widget_scroll_event (GtkWidget* _sender,
                                              GdkEventScroll* event,
                                              gpointer self);
static void bird_font_glyph_canvas_area_finalize (GObject * obj);
static GType bird_font_glyph_canvas_area_get_type_once (void);

static inline gpointer
bird_font_gtk_window_get_instance_private (BirdFontGtkWindow* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontGtkWindow_private_offset);
}

static void
_bird_font_gtk_window_idle_bird_font_task_runnable (gpointer self)
{
	bird_font_gtk_window_idle ();
}

BirdFontGtkWindow*
bird_font_gtk_window_construct (GType object_type,
                                const gchar* title)
{
	BirdFontGtkWindow * self = NULL;
	g_return_val_if_fail (title != NULL, NULL);
	self = (BirdFontGtkWindow*) g_object_new (object_type, NULL);
	gtk_window_set_title (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), "BirdFont");
	return self;
}

BirdFontGtkWindow*
bird_font_gtk_window_new (const gchar* title)
{
	return bird_font_gtk_window_construct (BIRD_FONT_TYPE_GTK_WINDOW, title);
}

void
bird_font_gtk_window_idle (void)
{
}

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

static gboolean
__lambda18_ (BirdFontGtkWindow* self)
{
	gboolean result;
	bird_font_menu_tab_quit ();
	result = TRUE;
	return result;
}

static gboolean
___lambda18__gtk_widget_delete_event (GtkWidget* _sender,
                                      GdkEventAny* event,
                                      gpointer self)
{
	gboolean result;
	result = __lambda18_ ((BirdFontGtkWindow*) self);
	return result;
}

static void
__lambda19_ (BirdFontGtkWindow* self,
             BirdFontTabBar* f,
             BirdFontTab* tab)
{
	gchar* uri = NULL;
	gchar* _tmp0_;
	gchar* html = NULL;
	gchar* _tmp1_;
	BirdFontFontDisplay* fd = NULL;
	BirdFontFontDisplay* _tmp2_;
	BirdFontFontDisplay* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gboolean _tmp6_;
	g_return_if_fail (f != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = g_strdup ("");
	uri = _tmp0_;
	_tmp1_ = g_strdup ("");
	html = _tmp1_;
	_tmp2_ = bird_font_tab_get_display (tab);
	fd = _tmp2_;
	_tmp3_ = fd;
	_tmp4_ = bird_font_font_display_get_name (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strcmp0 (_tmp5_, "Preview") == 0;
	_g_free0 (_tmp5_);
	if (_tmp6_) {
		gchar* _tmp7_;
		gchar* _tmp8_;
		WebKitWebView* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		GtkScrolledWindow* _tmp12_;
		BirdFontGlyphCanvasArea* _tmp13_;
		_tmp7_ = bird_font_preview_get_uri ();
		_g_free0 (uri);
		uri = _tmp7_;
		_tmp8_ = bird_font_preview_get_html_with_absolute_paths ();
		_g_free0 (html);
		html = _tmp8_;
		_tmp9_ = self->priv->html_canvas;
		_tmp10_ = html;
		_tmp11_ = uri;
		webkit_web_view_load_html (_tmp9_, _tmp10_, _tmp11_);
		_tmp12_ = self->priv->html_box;
		gtk_widget_set_visible ((GtkWidget*) _tmp12_, TRUE);
		_tmp13_ = self->priv->glyph_canvas_area;
		gtk_widget_set_visible ((GtkWidget*) _tmp13_, FALSE);
	} else {
		GtkScrolledWindow* _tmp14_;
		BirdFontGlyphCanvasArea* _tmp15_;
		_tmp14_ = self->priv->html_box;
		gtk_widget_set_visible ((GtkWidget*) _tmp14_, FALSE);
		_tmp15_ = self->priv->glyph_canvas_area;
		gtk_widget_set_visible ((GtkWidget*) _tmp15_, TRUE);
	}
	_g_object_unref0 (fd);
	_g_free0 (html);
	_g_free0 (uri);
}

static void
___lambda19__bird_font_tab_bar_signal_tab_selected (BirdFontTabBar* _sender,
                                                    BirdFontTab* selected_tab,
                                                    gpointer self)
{
	__lambda19_ ((BirdFontGtkWindow*) self, _sender, selected_tab);
}

static gboolean
__lambda20_ (BirdFontGtkWindow* self,
             GtkWidget* t,
             cairo_t* e)
{
	BirdFontGlyphCanvasArea* _tmp0_;
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = self->priv->glyph_canvas_area;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, FALSE);
	result = FALSE;
	return result;
}

static gboolean
___lambda20__gtk_widget_draw (GtkWidget* _sender,
                              cairo_t* cr,
                              gpointer self)
{
	gboolean result;
	result = __lambda20_ ((BirdFontGtkWindow*) self, _sender, cr);
	return result;
}

static gboolean
__lambda26_ (BirdFontGtkWindow* self,
             GtkWidget* t,
             GdkEventKey* event)
{
	gunichar c = 0U;
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	c = (gunichar) gdk_keyval_to_unicode (event->keyval);
	if (c != ((gunichar) '\0')) {
		bird_font_tab_content_key_press ((guint) c);
	} else {
		bird_font_tab_content_key_press (event->keyval);
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda26__gtk_widget_key_press_event (GtkWidget* _sender,
                                         GdkEventKey* event,
                                         gpointer self)
{
	gboolean result;
	result = __lambda26_ ((BirdFontGtkWindow*) self, _sender, event);
	return result;
}

static gboolean
__lambda27_ (BirdFontGtkWindow* self,
             GtkWidget* t,
             GdkEventKey* event)
{
	gunichar c = 0U;
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	c = (gunichar) gdk_keyval_to_unicode (event->keyval);
	if (c != ((gunichar) '\0')) {
		bird_font_tab_content_key_release ((guint) c);
	} else {
		bird_font_tab_content_key_release (event->keyval);
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda27__gtk_widget_key_release_event (GtkWidget* _sender,
                                           GdkEventKey* event,
                                           gpointer self)
{
	gboolean result;
	result = __lambda27_ ((BirdFontGtkWindow*) self, _sender, event);
	return result;
}

static void
__lambda28_ (BirdFontGtkWindow* self)
{
	bird_font_glyph_canvas_redraw ();
}

static void
___lambda28__gtk_widget_size_allocate (GtkWidget* _sender,
                                       GtkAllocation* allocation,
                                       gpointer self)
{
	__lambda28_ ((BirdFontGtkWindow*) self);
}

void
bird_font_gtk_window_init (BirdFontGtkWindow* self)
{
	GdkDisplay* _tmp0_;
	GtkClipboard* _tmp1_;
	GtkClipboard* _tmp2_;
	BirdFontGlyphCanvas* _tmp3_;
	BirdFontGlyphCanvasArea* _tmp4_;
	WebKitWebView* _tmp5_;
	GtkScrolledWindow* _tmp6_;
	GtkScrolledWindow* _tmp7_;
	GtkScrolledWindow* _tmp8_;
	WebKitWebView* _tmp9_;
	BirdFontTabBar* _tmp10_;
	BirdFontTabBar* _tmp11_;
	WebKitWebView* _tmp12_;
	GtkBox* _tmp13_;
	GtkBox* _tmp14_;
	BirdFontGlyphCanvasArea* _tmp15_;
	GtkBox* _tmp16_;
	GtkScrolledWindow* _tmp17_;
	GtkBox* _tmp18_;
	GtkBox* _tmp19_;
	BirdFontTabBar* _tmp20_;
	BirdFontTabBar* _tmp21_;
	BirdFontTabbarCanvas* _tmp22_;
	BirdFontTabbarCanvas* _tmp23_;
	GtkBox* _tmp24_;
	GtkBox* _tmp25_;
	BirdFontToolbox* _tmp26_;
	BirdFontToolbox* _tmp27_;
	BirdFontToolboxCanvas* _tmp28_;
	GtkBox* _tmp29_;
	GtkBox* _tmp30_;
	BirdFontToolboxCanvas* _tmp31_;
	GtkBox* _tmp32_;
	GtkBox* _tmp33_;
	GtkBox* vbox = NULL;
	GtkBox* _tmp34_;
	GtkBox* _tmp35_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	notify_init ("BirdFont");
	g_signal_connect (self, "notify::is-active", (GCallback) bird_font_gtk_window_window_focus, NULL);
	_tmp0_ = gtk_widget_get_display ((GtkWidget*) self);
	_tmp1_ = gtk_clipboard_get_for_display (_tmp0_, GDK_SELECTION_CLIPBOARD);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (self->priv->clipboard);
	self->priv->clipboard = _tmp2_;
	g_signal_connect_object ((GtkWidget*) self, "delete-event", (GCallback) ___lambda18__gtk_widget_delete_event, self, 0);
	bird_font_gtk_window_set_size_and_position (self);
	_tmp3_ = bird_font_main_window_glyph_canvas;
	_tmp4_ = bird_font_glyph_canvas_area_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->glyph_canvas_area);
	self->priv->glyph_canvas_area = _tmp4_;
	_tmp5_ = (WebKitWebView*) webkit_web_view_new ();
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->html_canvas);
	self->priv->html_canvas = _tmp5_;
	_tmp6_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->priv->html_box);
	self->priv->html_box = _tmp6_;
	_tmp7_ = self->priv->html_box;
	gtk_scrolled_window_set_policy (_tmp7_, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	_tmp8_ = self->priv->html_box;
	_tmp9_ = self->priv->html_canvas;
	gtk_container_add ((GtkContainer*) _tmp8_, (GtkWidget*) _tmp9_);
	_tmp10_ = bird_font_main_window_get_tab_bar ();
	_tmp11_ = _tmp10_;
	g_signal_connect_object (_tmp11_, "signal-tab-selected", (GCallback) ___lambda19__bird_font_tab_bar_signal_tab_selected, self, 0);
	_g_object_unref0 (_tmp11_);
	_tmp12_ = self->priv->html_canvas;
	g_signal_connect_object ((GtkWidget*) _tmp12_, "draw", (GCallback) ___lambda20__gtk_widget_draw, self, 0);
	_tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->canvas_box);
	self->priv->canvas_box = _tmp13_;
	_tmp14_ = self->priv->canvas_box;
	_tmp15_ = self->priv->glyph_canvas_area;
	gtk_box_pack_start (_tmp14_, (GtkWidget*) _tmp15_, TRUE, TRUE, (guint) 0);
	_tmp16_ = self->priv->canvas_box;
	_tmp17_ = self->priv->html_box;
	gtk_box_pack_start (_tmp16_, (GtkWidget*) _tmp17_, TRUE, TRUE, (guint) 0);
	_tmp18_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->tab_box);
	self->priv->tab_box = _tmp18_;
	_tmp19_ = self->priv->tab_box;
	_tmp20_ = bird_font_main_window_get_tab_bar ();
	_tmp21_ = _tmp20_;
	_tmp22_ = bird_font_tabbar_canvas_new (_tmp21_);
	g_object_ref_sink (_tmp22_);
	_tmp23_ = _tmp22_;
	gtk_box_pack_start (_tmp19_, (GtkWidget*) _tmp23_, FALSE, FALSE, (guint) 0);
	_g_object_unref0 (_tmp23_);
	_g_object_unref0 (_tmp21_);
	_tmp24_ = self->priv->tab_box;
	_tmp25_ = self->priv->canvas_box;
	gtk_box_pack_start (_tmp24_, (GtkWidget*) _tmp25_, TRUE, TRUE, (guint) 0);
	_tmp26_ = bird_font_main_window_get_toolbox ();
	_tmp27_ = _tmp26_;
	_tmp28_ = bird_font_toolbox_canvas_new (_tmp27_);
	g_object_ref_sink (_tmp28_);
	_g_object_unref0 (self->priv->toolbox);
	self->priv->toolbox = _tmp28_;
	_g_object_unref0 (_tmp27_);
	_tmp29_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp29_);
	_g_object_unref0 (self->priv->list_box);
	self->priv->list_box = _tmp29_;
	_tmp30_ = self->priv->list_box;
	_tmp31_ = self->priv->toolbox;
	gtk_box_pack_start (_tmp30_, (GtkWidget*) _tmp31_, FALSE, FALSE, (guint) 0);
	_tmp32_ = self->priv->list_box;
	_tmp33_ = self->priv->tab_box;
	gtk_box_pack_start (_tmp32_, (GtkWidget*) _tmp33_, TRUE, TRUE, (guint) 0);
	_tmp34_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp34_);
	vbox = _tmp34_;
	_tmp35_ = self->priv->list_box;
	gtk_box_pack_start (vbox, (GtkWidget*) _tmp35_, TRUE, TRUE, (guint) 0);
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) vbox);
	{
		GFile* _tmp36_;
		GFile* _tmp37_;
		gchar* _tmp38_;
		gchar* _tmp39_;
		_tmp36_ = bird_font_search_paths_find_file (NULL, "birdfont_window_icon.png");
		_tmp37_ = _tmp36_;
		_tmp38_ = g_file_get_path (_tmp37_);
		_tmp39_ = (gchar*) _tmp38_;
		gtk_window_set_icon_from_file ((GtkWindow*) self, _tmp39_, &_inner_error0_);
		_g_free0 (_tmp39_);
		_g_object_unref0 (_tmp37_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp40_;
		const gchar* _tmp41_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp40_ = e;
		_tmp41_ = _tmp40_->message;
		g_warning ("GtkWindow.vala:122: %s", _tmp41_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (vbox);
		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_signal_connect_object ((GtkWidget*) self, "key-press-event", (GCallback) ___lambda26__gtk_widget_key_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "key-release-event", (GCallback) ___lambda27__gtk_widget_key_release_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "size-allocate", (GCallback) ___lambda28__gtk_widget_size_allocate, self, 0);
	gtk_widget_show_all ((GtkWidget*) self);
	bird_font_main_window_open_recent_files_tab ();
	_g_object_unref0 (vbox);
}

void
bird_font_gtk_window_window_focus (BirdFontGtkWindow* self,
                                   void* data)
{
	g_return_if_fail (self != NULL);
	bird_font_tab_content_reset_modifier ();
}

void
bird_font_gtk_window_reset_modifier (GdkModifierType flags)
{
	if ((flags & GDK_CONTROL_MASK) == 0) {
		bird_font_tab_content_key_release ((guint) BIRD_FONT_KEY_CTRL_RIGHT);
		bird_font_tab_content_key_release ((guint) BIRD_FONT_KEY_CTRL_LEFT);
	}
	if ((flags & GDK_SHIFT_MASK) == 0) {
		bird_font_tab_content_key_release ((guint) BIRD_FONT_KEY_SHIFT_LEFT);
		bird_font_tab_content_key_release ((guint) BIRD_FONT_KEY_SHIFT_RIGHT);
	}
	if ((flags & GDK_MOD1_MASK) == 0) {
		bird_font_tab_content_key_release ((guint) BIRD_FONT_KEY_ALT_LEFT);
		bird_font_tab_content_key_release ((guint) BIRD_FONT_KEY_ALT_RIGHT);
	}
	if ((flags & GDK_MOD5_MASK) == 0) {
		bird_font_tab_content_key_release ((guint) BIRD_FONT_KEY_LOGO_LEFT);
		bird_font_tab_content_key_release ((guint) BIRD_FONT_KEY_LOGO_RIGHT);
	}
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
bird_font_gtk_window_real_font_loaded (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	BirdFontFont* f = NULL;
	BirdFontFont* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = (BirdFontGtkWindow*) base;
	_tmp0_ = bird_font_bird_font_get_current_font ();
	f = _tmp0_;
	_tmp1_ = f->full_name;
	_tmp2_ = string_to_string (_tmp1_);
	gtk_window_set_title ((GtkWindow*) self, _tmp2_);
	_g_object_unref0 (f);
}

void
bird_font_gtk_window_dump_clipboard_content (BirdFontGtkWindow* self,
                                             GtkClipboard* clipboard,
                                             GtkSelectionData* selection_data)
{
	gchar* d = NULL;
	gchar* _tmp0_;
	FILE* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (clipboard != NULL);
	g_return_if_fail (selection_data != NULL);
	g_return_if_fail (!bird_font_is_null (selection_data));
	_tmp0_ = g_strdup ((const gchar*) ((GtkSelectionData*) selection_data));
	_g_free0 (d);
	d = _tmp0_;
	_tmp1_ = stdout;
	fprintf (_tmp1_, "%s", d);
	_g_free0 (d);
}

static void
_bird_font_gtk_window_dump_clipboard_content_gtk_clipboard_received_func (GtkClipboard* clipboard,
                                                                          GtkSelectionData* selection_data,
                                                                          gpointer self)
{
	bird_font_gtk_window_dump_clipboard_content ((BirdFontGtkWindow*) self, clipboard, selection_data);
	g_object_unref (self);
}

void
bird_font_gtk_window_dump_clipboard_target (BirdFontGtkWindow* self,
                                            GtkClipboard* clipboard,
                                            GdkAtom* atoms,
                                            gint atoms_length1)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (clipboard != NULL);
	if (atoms != NULL) {
		{
			GdkAtom* target_collection = NULL;
			gint target_collection_length1 = 0;
			gint _target_collection_size_ = 0;
			gint target_it = 0;
			target_collection = (GdkAtom*) atoms;
			target_collection_length1 = (atoms_length1 * sizeof (GdkAtom)) / sizeof (GdkAtom);
			for (target_it = 0; target_it < target_collection_length1; target_it = target_it + 1) {
				GdkAtom target = (GdkAtom) 0U;
				target = target_collection[target_it];
				{
					gchar* _tmp0_;
					gchar* _tmp1_;
					gchar* _tmp2_;
					gchar* _tmp3_;
					gchar* _tmp4_;
					gchar* _tmp5_;
					_tmp0_ = gdk_atom_name (target);
					_tmp1_ = _tmp0_;
					_tmp2_ = g_strconcat ("Target: ", _tmp1_, NULL);
					_tmp3_ = _tmp2_;
					_tmp4_ = g_strconcat (_tmp3_, "\n", NULL);
					_tmp5_ = _tmp4_;
					g_print ("%s", _tmp5_);
					_g_free0 (_tmp5_);
					_g_free0 (_tmp3_);
					_g_free0 (_tmp1_);
					gtk_clipboard_request_contents (clipboard, target, _bird_font_gtk_window_dump_clipboard_content_gtk_clipboard_received_func, g_object_ref (self));
				}
			}
		}
	}
}

static void
_bird_font_gtk_window_dump_clipboard_target_gtk_clipboard_targets_received_func (GtkClipboard* clipboard,
                                                                                 GdkAtom* atoms,
                                                                                 gint n_atoms,
                                                                                 gpointer self)
{
	bird_font_gtk_window_dump_clipboard_target ((BirdFontGtkWindow*) self, clipboard, atoms, n_atoms);
	g_object_unref (self);
}

void
bird_font_gtk_window_dump_clipboard (BirdFontGtkWindow* self)
{
	GtkClipboard* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->clipboard;
	gtk_clipboard_request_targets (_tmp0_, _bird_font_gtk_window_dump_clipboard_target_gtk_clipboard_targets_received_func, g_object_ref (self));
}

static void
_vala_GtkSelectionData_free (GtkSelectionData* self)
{
	g_boxed_free (gtk_selection_data_get_type (), self);
}

static gchar*
bird_font_gtk_window_real_get_clipboard_data (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	GtkSelectionData* selection_data = NULL;
	GdkAtom target = (GdkAtom) 0U;
	gchar* t = NULL;
	GtkClipboard* _tmp0_;
	GtkSelectionData* _tmp1_;
	GtkSelectionData* _tmp2_;
	GtkClipboard* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp11_;
	gchar* result;
	self = (BirdFontGtkWindow*) base;
	target = gdk_atom_intern_static_string ("image/x-inkscape-svg");
	_tmp0_ = self->priv->clipboard;
	_tmp1_ = gtk_clipboard_wait_for_contents (_tmp0_, target);
	__vala_GtkSelectionData_free0 (selection_data);
	selection_data = _tmp1_;
	_tmp2_ = selection_data;
	if (!bird_font_is_null (_tmp2_)) {
		GtkSelectionData* _tmp3_;
		guint8* _tmp4_;
		gchar* _tmp5_;
		_tmp3_ = selection_data;
		_tmp4_ = gtk_selection_data_get_data ((GtkSelectionData*) _tmp3_);
		_tmp5_ = g_strdup ((const gchar*) _tmp4_);
		result = _tmp5_;
		_g_free0 (t);
		__vala_GtkSelectionData_free0 (selection_data);
		return result;
	}
	_tmp6_ = self->priv->clipboard;
	_tmp7_ = gtk_clipboard_wait_for_text (_tmp6_);
	_g_free0 (t);
	t = _tmp7_;
	_tmp8_ = t;
	if (_tmp8_ != NULL) {
		const gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp9_ = t;
		_tmp10_ = g_strdup ((const gchar*) _tmp9_);
		result = _tmp10_;
		_g_free0 (t);
		__vala_GtkSelectionData_free0 (selection_data);
		return result;
	}
	_tmp11_ = g_strdup ("");
	result = _tmp11_;
	_g_free0 (t);
	__vala_GtkSelectionData_free0 (selection_data);
	return result;
}

static gchar*
string_to_utf8 (const gchar* self,
                gint* result_length1)
{
	gint string_length = 0;
	gint _tmp0_;
	gint _tmp1_;
	gchar* _result_ = NULL;
	gchar* _tmp2_;
	gint _result__length1;
	gint __result__size_;
	gint _tmp3_;
	gchar* _tmp4_;
	gint _tmp4__length1;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = _tmp1_;
	_tmp2_ = g_new0 (gchar, string_length + 1);
	_result_ = _tmp2_;
	_result__length1 = string_length + 1;
	__result__size_ = _result__length1;
	_tmp3_ = _result__length1;
	_result__length1 = _tmp3_ - 1;
	memcpy (_result_, self, (gsize) string_length);
	_tmp4_ = _result_;
	_tmp4__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}

static void
___lambda29_ (GtkClipboard* clipboard,
              GtkSelectionData* selection_data,
              guint info,
              void* owner)
{
	GdkAtom type = (GdkAtom) 0U;
	guchar* data = NULL;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gchar* _tmp2_;
	gint data_length1;
	gint _data_size_;
	g_return_if_fail (clipboard != NULL);
	g_return_if_fail (selection_data != NULL);
	_tmp0_ = ((BirdFontGtkWindow*) owner)->priv->inkscape_clipboard;
	_tmp2_ = string_to_utf8 (_tmp0_, &_tmp1_);
	data = (guchar*) ((gchar*) _tmp2_);
	data_length1 = (((_tmp1_ * sizeof (gchar)) / sizeof (gchar)) * sizeof (gchar)) / sizeof (guchar);
	_data_size_ = data_length1;
	type = gdk_atom_intern_static_string ("image/x-inkscape-svg");
	gtk_selection_data_set (selection_data, type, 8, data, (gint) data_length1);
	data = (g_free (data), NULL);
}

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

static void
___lambda30_ (GtkClipboard* clipboard,
              void* user_data)
{
	g_return_if_fail (clipboard != NULL);
}

static void
____lambda30__gtk_clipboard_clear_func (GtkClipboard* clipboard,
                                        void* user_data_or_owner)
{
	___lambda30_ (clipboard, user_data_or_owner);
}

static void
bird_font_gtk_window_real_set_inkscape_clipboard (BirdFontNativeWindow* base,
                                                  const gchar* inkscape_clipboard_data)
{
	BirdFontGtkWindow * self;
	self = (BirdFontGtkWindow*) base;
	g_return_if_fail (inkscape_clipboard_data != NULL);
	if (bird_font_bird_font_mac) {
		GtkClipboard* _tmp0_;
		_tmp0_ = self->priv->clipboard;
		gtk_clipboard_set_text (_tmp0_, inkscape_clipboard_data, -1);
	} else {
		GtkTargetEntry t = {0};
		GtkTargetEntry _tmp1_ = {0};
		GtkTargetEntry* targets = NULL;
		GtkTargetEntry _tmp2_;
		GtkTargetEntry* _tmp3_;
		gint targets_length1;
		gint _targets_size_;
		gchar* _tmp4_;
		GtkClipboard* _tmp5_;
		GtkTargetEntry* _tmp6_;
		gint _tmp6__length1;
		_tmp1_.target = "image/x-inkscape-svg";
		_tmp1_.flags = (guint) 0;
		_tmp1_.info = (guint) 0;
		t = _tmp1_;
		_tmp2_ = t;
		_tmp3_ = g_new0 (GtkTargetEntry, 1);
		_tmp3_[0] = _tmp2_;
		targets = _tmp3_;
		targets_length1 = 1;
		_targets_size_ = targets_length1;
		_tmp4_ = g_strdup (inkscape_clipboard_data);
		_g_free0 (self->priv->inkscape_clipboard);
		self->priv->inkscape_clipboard = _tmp4_;
		_tmp5_ = self->priv->clipboard;
		_tmp6_ = targets;
		_tmp6__length1 = targets_length1;
		gtk_clipboard_set_with_owner (_tmp5_, _tmp6_, (guint) _tmp6__length1, ____lambda29__gtk_clipboard_get_func, ____lambda30__gtk_clipboard_clear_func, (GObject*) self);
		targets = (g_free (targets), NULL);
	}
}

static void
bird_font_gtk_window_real_set_clipboard_text (BirdFontNativeWindow* base,
                                              const gchar* text)
{
	BirdFontGtkWindow * self;
	GtkClipboard* _tmp0_;
	self = (BirdFontGtkWindow*) base;
	g_return_if_fail (text != NULL);
	_tmp0_ = self->priv->clipboard;
	gtk_clipboard_set_text (_tmp0_, text, -1);
}

static gchar*
bird_font_gtk_window_real_get_clipboard_text (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	gchar* t = NULL;
	GtkClipboard* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp5_;
	gchar* result;
	self = (BirdFontGtkWindow*) base;
	_tmp0_ = self->priv->clipboard;
	_tmp1_ = gtk_clipboard_wait_for_text (_tmp0_);
	_g_free0 (t);
	t = _tmp1_;
	_tmp2_ = t;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = t;
		_tmp4_ = g_strdup ((const gchar*) _tmp3_);
		result = _tmp4_;
		_g_free0 (t);
		return result;
	}
	_tmp5_ = g_strdup ("");
	result = _tmp5_;
	_g_free0 (t);
	return result;
}

static void
__lambda31_ (GtkClipboard* clipboard,
             GtkSelectionData* selection_data,
             guint info,
             void* owner)
{
	GdkAtom type = (GdkAtom) 0U;
	guchar* data = NULL;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gchar* _tmp2_;
	gint data_length1;
	gint _data_size_;
	g_return_if_fail (clipboard != NULL);
	g_return_if_fail (selection_data != NULL);
	_tmp0_ = ((BirdFontGtkWindow*) owner)->priv->clipboard_svg;
	_tmp2_ = string_to_utf8 (_tmp0_, &_tmp1_);
	data = (guchar*) ((gchar*) _tmp2_);
	data_length1 = (((_tmp1_ * sizeof (gchar)) / sizeof (gchar)) * sizeof (gchar)) / sizeof (guchar);
	_data_size_ = data_length1;
	type = gdk_atom_intern_static_string ("image/svg+xml");
	gtk_selection_data_set (selection_data, type, 0, data, (gint) data_length1);
	data = (g_free (data), NULL);
}

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

static void
__lambda32_ (GtkClipboard* clipboard,
             void* user_data)
{
	g_return_if_fail (clipboard != NULL);
}

static void
___lambda32__gtk_clipboard_clear_func (GtkClipboard* clipboard,
                                       void* user_data_or_owner)
{
	__lambda32_ (clipboard, user_data_or_owner);
}

static void
bird_font_gtk_window_real_set_clipboard (BirdFontNativeWindow* base,
                                         const gchar* svg)
{
	BirdFontGtkWindow * self;
	GtkTargetEntry t = {0};
	GtkTargetEntry _tmp0_ = {0};
	GtkTargetEntry* targets = NULL;
	GtkTargetEntry _tmp1_;
	GtkTargetEntry* _tmp2_;
	gint targets_length1;
	gint _targets_size_;
	gchar* _tmp3_;
	GtkClipboard* _tmp4_;
	self = (BirdFontGtkWindow*) base;
	g_return_if_fail (svg != NULL);
	_tmp0_.target = "image/svg+xml";
	_tmp0_.flags = (guint) 0;
	_tmp0_.info = (guint) 0;
	t = _tmp0_;
	_tmp1_ = t;
	_tmp2_ = g_new0 (GtkTargetEntry, 1);
	_tmp2_[0] = _tmp1_;
	targets = _tmp2_;
	targets_length1 = 1;
	_targets_size_ = targets_length1;
	_tmp3_ = g_strdup (svg);
	_g_free0 (self->priv->clipboard_svg);
	self->priv->clipboard_svg = _tmp3_;
	_tmp4_ = self->priv->clipboard;
	gtk_clipboard_set_with_owner (_tmp4_, targets, (guint) targets_length1, ___lambda31__gtk_clipboard_get_func, ___lambda32__gtk_clipboard_clear_func, (GObject*) self);
	targets = (g_free (targets), NULL);
}

static void
bird_font_gtk_window_real_update_window_size (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	gint w = 0;
	gint h = 0;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	self = (BirdFontGtkWindow*) base;
	gtk_window_get_size ((GtkWindow*) self, &_tmp0_, &_tmp1_);
	w = _tmp0_;
	h = _tmp1_;
	_tmp2_ = g_strdup_printf ("%i", w);
	_tmp3_ = _tmp2_;
	bird_font_preferences_set ("window_width", _tmp3_);
	_g_free0 (_tmp3_);
	_tmp4_ = g_strdup_printf ("%i", h);
	_tmp5_ = _tmp4_;
	bird_font_preferences_set ("window_height", _tmp5_);
	_g_free0 (_tmp5_);
}

static void
bird_font_gtk_window_set_size_and_position (BirdFontGtkWindow* self)
{
	gint w = 0;
	gint h = 0;
	g_return_if_fail (self != NULL);
	w = bird_font_preferences_get_window_width ();
	h = bird_font_preferences_get_window_height ();
	gtk_window_set_default_size ((GtkWindow*) self, w, h);
}

static void
bird_font_gtk_window_real_quit (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	self = (BirdFontGtkWindow*) base;
	gtk_main_quit ();
}

static void
bird_font_gtk_window_real_file_chooser (BirdFontNativeWindow* base,
                                        const gchar* title,
                                        BirdFontFileChooser* fc,
                                        guint flags)
{
	BirdFontGtkWindow * self;
	gchar* fn = NULL;
	gboolean folder = FALSE;
	BirdFontArgument* _tmp0_;
	BirdFontArgument* _tmp1_;
	gboolean _tmp2_;
	const gchar* _tmp15_;
	self = (BirdFontGtkWindow*) base;
	g_return_if_fail (title != NULL);
	g_return_if_fail (fc != NULL);
	fn = NULL;
	_tmp0_ = bird_font_bird_font_get_arguments ();
	_tmp1_ = _tmp0_;
	_tmp2_ = bird_font_argument_has_argument (_tmp1_, "--windows");
	_g_object_unref0 (_tmp1_);
	if (_tmp2_) {
		folder = (flags & BIRD_FONT_FILE_CHOOSER_DIRECTORY) > ((guint) 0);
		bird_font_menu_tab_show_file_dialog_tab (title, fc, folder);
	} else {
		if ((flags & BIRD_FONT_FILE_CHOOSER_DIRECTORY) > ((guint) 0)) {
			if ((flags & BIRD_FONT_FILE_CHOOSER_LOAD) > ((guint) 0)) {
				gchar* _tmp3_;
				gchar* _tmp4_;
				gchar* _tmp5_;
				_tmp3_ = bird_font_t_ ("Open");
				_tmp4_ = _tmp3_;
				_tmp5_ = bird_font_gtk_window_show_file_chooser (self, title, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, _tmp4_);
				_g_free0 (fn);
				fn = _tmp5_;
				_g_free0 (_tmp4_);
			} else {
				if ((flags & BIRD_FONT_FILE_CHOOSER_SAVE) > ((guint) 0)) {
					gchar* _tmp6_;
					gchar* _tmp7_;
					gchar* _tmp8_;
					_tmp6_ = bird_font_t_ ("Save");
					_tmp7_ = _tmp6_;
					_tmp8_ = bird_font_gtk_window_show_file_chooser (self, title, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, _tmp7_);
					_g_free0 (fn);
					fn = _tmp8_;
					_g_free0 (_tmp7_);
				} else {
					g_warning ("GtkWindow.vala:333: Open or save is not set.");
				}
			}
		} else {
			if ((flags & BIRD_FONT_FILE_CHOOSER_LOAD) > ((guint) 0)) {
				gchar* _tmp9_;
				gchar* _tmp10_;
				gchar* _tmp11_;
				_tmp9_ = bird_font_t_ ("Open");
				_tmp10_ = _tmp9_;
				_tmp11_ = bird_font_gtk_window_show_file_chooser (self, title, GTK_FILE_CHOOSER_ACTION_OPEN, _tmp10_);
				_g_free0 (fn);
				fn = _tmp11_;
				_g_free0 (_tmp10_);
			} else {
				if ((flags & BIRD_FONT_FILE_CHOOSER_SAVE) > ((guint) 0)) {
					gchar* _tmp12_;
					gchar* _tmp13_;
					gchar* _tmp14_;
					_tmp12_ = bird_font_t_ ("Save");
					_tmp13_ = _tmp12_;
					_tmp14_ = bird_font_gtk_window_show_file_chooser (self, title, GTK_FILE_CHOOSER_ACTION_SAVE, _tmp13_);
					_g_free0 (fn);
					fn = _tmp14_;
					_g_free0 (_tmp13_);
				} else {
					g_warning ("GtkWindow.vala:340: Unknown type");
				}
			}
		}
	}
	_tmp15_ = fn;
	bird_font_file_chooser_selected (fc, _tmp15_);
	_g_free0 (fn);
}

static gint
string_last_index_of (const gchar* self,
                      const gchar* needle,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (needle != NULL, 0);
	_tmp0_ = g_strrstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

gchar*
bird_font_gtk_window_show_file_chooser (BirdFontGtkWindow* self,
                                        const gchar* title,
                                        GtkFileChooserAction action,
                                        const gchar* label)
{
	gchar* fn = NULL;
	GtkFileChooserDialog* file_chooser = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GtkFileChooserDialog* _tmp2_;
	GtkFileChooserDialog* _tmp3_;
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp4_;
	gint i = 0;
	gchar* last_folder = NULL;
	gchar* _tmp5_;
	GtkFileChooserDialog* _tmp18_;
	GtkFileChooserDialog* _tmp21_;
	const gchar* _tmp22_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	g_return_val_if_fail (label != NULL, NULL);
	fn = NULL;
	_tmp0_ = bird_font_t_ ("Cancel");
	_tmp1_ = _tmp0_;
	_tmp2_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new (title, (GtkWindow*) self, action, _tmp1_, GTK_RESPONSE_CANCEL, label, GTK_RESPONSE_ACCEPT, NULL);
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	file_chooser = _tmp3_;
	_tmp4_ = bird_font_bird_font_get_current_font ();
	font = _tmp4_;
	_tmp5_ = bird_font_preferences_get ("last_folder");
	_g_free0 (last_folder);
	last_folder = _tmp5_;
	{
		const gchar* _tmp6_;
		_tmp6_ = last_folder;
		if (g_strcmp0 (_tmp6_, "") == 0) {
			GtkFileChooserDialog* _tmp7_;
			BirdFontFont* _tmp8_;
			GFile* _tmp9_;
			GFile* _tmp10_;
			_tmp7_ = file_chooser;
			_tmp8_ = font;
			_tmp9_ = bird_font_font_get_folder (_tmp8_);
			_tmp10_ = _tmp9_;
			gtk_file_chooser_set_current_folder_file ((GtkFileChooser*) _tmp7_, _tmp10_, &_inner_error0_);
			_g_object_unref0 (_tmp10_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		} else {
			GtkFileChooserDialog* _tmp11_;
			const gchar* _tmp12_;
			GFile* _tmp13_;
			GFile* _tmp14_;
			_tmp11_ = file_chooser;
			_tmp12_ = last_folder;
			_tmp13_ = g_file_new_for_path (_tmp12_);
			_tmp14_ = _tmp13_;
			gtk_file_chooser_set_current_folder_file ((GtkFileChooser*) _tmp11_, _tmp14_, &_inner_error0_);
			_g_object_unref0 (_tmp14_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		FILE* _tmp15_;
		GError* _tmp16_;
		const gchar* _tmp17_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp15_ = stderr;
		_tmp16_ = e;
		_tmp17_ = _tmp16_->message;
		fprintf (_tmp15_, "%s", _tmp17_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (last_folder);
		_g_object_unref0 (font);
		_g_object_unref0 (file_chooser);
		_g_free0 (fn);
		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;
	}
	_tmp18_ = file_chooser;
	if (gtk_dialog_run ((GtkDialog*) _tmp18_) == ((gint) GTK_RESPONSE_ACCEPT)) {
		GtkFileChooserDialog* _tmp19_;
		gchar* _tmp20_;
		bird_font_glyph_canvas_redraw ();
		_tmp19_ = file_chooser;
		_tmp20_ = gtk_file_chooser_get_filename ((GtkFileChooser*) _tmp19_);
		_g_free0 (fn);
		fn = _tmp20_;
	}
	_tmp21_ = file_chooser;
	gtk_widget_destroy ((GtkWidget*) _tmp21_);
	_tmp22_ = fn;
	if (_tmp22_ != NULL) {
		const gchar* _tmp23_;
		_tmp23_ = fn;
		i = string_last_index_of ((const gchar*) _tmp23_, "/", 0);
		if (i > -1) {
			const gchar* _tmp24_;
			gchar* _tmp25_;
			const gchar* _tmp26_;
			const gchar* _tmp27_;
			_tmp24_ = fn;
			_tmp25_ = string_substring ((const gchar*) _tmp24_, (glong) 0, (glong) i);
			_g_free0 (last_folder);
			last_folder = _tmp25_;
			_tmp26_ = last_folder;
			_tmp27_ = string_to_string (_tmp26_);
			bird_font_preferences_set ("last_folder", _tmp27_);
		}
	}
	result = fn;
	_g_free0 (last_folder);
	_g_object_unref0 (font);
	_g_object_unref0 (file_chooser);
	return result;
}

static gboolean
bird_font_gtk_window_real_convert_to_png (BirdFontNativeWindow* base,
                                          const gchar* from,
                                          const gchar* to)
{
	BirdFontGtkWindow * self;
	GdkPixbuf* pixbuf = NULL;
	gchar* folder = NULL;
	gint i = 0;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (BirdFontGtkWindow*) base;
	g_return_val_if_fail (from != NULL, FALSE);
	g_return_val_if_fail (to != NULL, FALSE);
	{
		GdkPixbuf* _tmp2_ = NULL;
		GdkPixbuf* _tmp3_;
		GdkPixbuf* _tmp4_;
		GdkPixbuf* _tmp5_;
		i = string_last_index_of (to, "/", 0);
		if (i != -1) {
			gchar* _tmp0_;
			const gchar* _tmp1_;
			_tmp0_ = string_substring (to, (glong) 0, (glong) i);
			_g_free0 (folder);
			folder = _tmp0_;
			_tmp1_ = folder;
			g_mkdir (_tmp1_, 0xFFFFFF);
		}
		_tmp3_ = gdk_pixbuf_new_from_file (from, &_inner_error0_);
		_tmp2_ = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp4_ = _tmp2_;
		_tmp2_ = NULL;
		_g_object_unref0 (pixbuf);
		pixbuf = _tmp4_;
		_tmp5_ = pixbuf;
		gdk_pixbuf_save (_tmp5_, to, "png", &_inner_error0_, NULL);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp2_);
			goto __catch0_g_error;
		}
		_g_object_unref0 (_tmp2_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_warning ("GtkWindow.vala:399: %s", _tmp7_);
		result = FALSE;
		_g_error_free0 (e);
		_g_free0 (folder);
		_g_object_unref0 (pixbuf);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp8_ = FALSE;
		_g_free0 (folder);
		_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 _tmp8_;
	}
	result = TRUE;
	_g_free0 (folder);
	_g_object_unref0 (pixbuf);
	return result;
}

static gpointer
_bird_font_gtk_window_background_thread_gthread_func (gpointer self)
{
	gpointer result;
	result = bird_font_gtk_window_background_thread ((BirdFontGtkWindow*) self);
	g_object_unref (self);
	return result;
}

static void
bird_font_gtk_window_real_run_background_thread (BirdFontNativeWindow* base,
                                                 BirdFontTask* t)
{
	BirdFontGtkWindow * self;
	GThread* bg = NULL;
	BirdFontTask* _tmp0_;
	GError* _inner_error0_ = NULL;
	self = (BirdFontGtkWindow*) base;
	g_return_if_fail (t != NULL);
	bird_font_menu_tab_start_background_thread ();
	_tmp0_ = _g_object_ref0 (t);
	_g_object_unref0 (self->priv->background_task);
	self->priv->background_task = _tmp0_;
	{
		GThread* _tmp1_ = NULL;
		GThread* _tmp2_;
		_tmp2_ = g_thread_try_new ("bg", _bird_font_gtk_window_background_thread_gthread_func, g_object_ref (self), &_inner_error0_);
		_tmp1_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		bg = _tmp1_;
		_g_thread_unref0 (_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning ("GtkWindow.vala:415: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static gpointer
_bird_font_task_perform_task_gthread_func (gpointer self)
{
	gpointer result;
	result = bird_font_task_perform_task ((BirdFontTask*) self);
	g_object_unref (self);
	return result;
}

static void
bird_font_gtk_window_real_run_non_blocking_background_thread (BirdFontNativeWindow* base,
                                                              BirdFontTask* t)
{
	BirdFontGtkWindow * self;
	GThread* bg = NULL;
	GError* _inner_error0_ = NULL;
	self = (BirdFontGtkWindow*) base;
	g_return_if_fail (t != NULL);
	{
		GThread* _tmp0_ = NULL;
		GThread* _tmp1_;
		_tmp1_ = g_thread_try_new ("bg", _bird_font_task_perform_task_gthread_func, g_object_ref (t), &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		bg = _tmp0_;
		_g_thread_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("GtkWindow.vala:425: %s", _tmp3_);
		_g_error_free0 (e);
	}
	__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;
	}
}

void*
bird_font_gtk_window_background_thread (BirdFontGtkWindow* self)
{
	BirdFontTask* _tmp0_;
	void* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->background_task;
	bird_font_task_run (_tmp0_);
	bird_font_menu_tab_stop_background_thread ();
	result = NULL;
	return result;
}

/** Run export in a background thread. */
static gpointer
_bird_font_gtk_window_export_thread_gthread_func (gpointer self)
{
	gpointer result;
	result = bird_font_gtk_window_export_thread ((BirdFontGtkWindow*) self);
	g_object_unref (self);
	return result;
}

static void
bird_font_gtk_window_real_export_font (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	GThread* export_thread = NULL;
	GError* _inner_error0_ = NULL;
	self = (BirdFontGtkWindow*) base;
	bird_font_menu_tab_start_background_thread ();
	{
		GThread* _tmp0_ = NULL;
		GThread* _tmp1_;
		_tmp1_ = g_thread_try_new ("export_thread", _bird_font_gtk_window_export_thread_gthread_func, g_object_ref (self), &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		export_thread = _tmp0_;
		_g_thread_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("GtkWindow.vala:444: %s", _tmp3_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static gboolean
__lambda33_ (BirdFontGtkWindow* self)
{
	NotifyNotification* export_notification = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	NotifyNotification* _tmp2_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	_tmp0_ = bird_font_t_ ("Your fonts have been exported.");
	_tmp1_ = _tmp0_;
	_tmp2_ = notify_notification_new ("BirdFont", _tmp1_, NULL);
	_g_object_unref0 (export_notification);
	export_notification = _tmp2_;
	_g_free0 (_tmp1_);
	{
		notify_notification_show (export_notification, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning ("GtkWindow.vala:461: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp5_ = FALSE;
		_g_object_unref0 (export_notification);
		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 _tmp5_;
	}
	result = FALSE;
	_g_object_unref0 (export_notification);
	return result;
}

static gboolean
___lambda33__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda33_ ((BirdFontGtkWindow*) self);
	return result;
}

void*
bird_font_gtk_window_export_thread (BirdFontGtkWindow* self)
{
	GSource* idle = NULL;
	GSource* _tmp0_;
	void* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_idle_source_new ();
	idle = _tmp0_;
	bird_font_export_callback_export_fonts ();
	bird_font_menu_tab_stop_background_thread ();
	bird_font_menu_tab_signal_file_exported ();
	g_source_set_callback (idle, ___lambda33__gsource_func, g_object_ref (self), g_object_unref);
	g_source_attach (idle, NULL);
	result = NULL;
	_g_source_unref0 (idle);
	return result;
}

/** Load font in a background thread. */
static gpointer
_bird_font_gtk_window_loading_thread_gthread_func (gpointer self)
{
	gpointer result;
	result = bird_font_gtk_window_loading_thread ((BirdFontGtkWindow*) self);
	g_object_unref (self);
	return result;
}

static void
bird_font_gtk_window_real_load (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	GThread* thread = NULL;
	GError* _inner_error0_ = NULL;
	self = (BirdFontGtkWindow*) base;
	bird_font_menu_tab_start_background_thread ();
	{
		GThread* _tmp0_ = NULL;
		GThread* _tmp1_;
		_tmp1_ = g_thread_try_new ("thread", _bird_font_gtk_window_loading_thread_gthread_func, g_object_ref (self), &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		thread = _tmp0_;
		_g_thread_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("GtkWindow.vala:479: %s", _tmp3_);
		_g_error_free0 (e);
	}
	__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;
	}
}

void*
bird_font_gtk_window_loading_thread (BirdFontGtkWindow* self)
{
	BirdFontFont* _tmp0_;
	BirdFontFont* _tmp1_;
	void* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = bird_font_bird_font_get_current_font ();
	_tmp1_ = _tmp0_;
	bird_font_font_load (_tmp1_);
	_g_object_unref0 (_tmp1_);
	bird_font_menu_tab_stop_background_thread ();
	bird_font_menu_tab_signal_file_loaded ();
	result = NULL;
	return result;
}

/** Save font in a background thread. */
static gpointer
_bird_font_gtk_window_saving_thread_gthread_func (gpointer self)
{
	gpointer result;
	result = bird_font_gtk_window_saving_thread ((BirdFontGtkWindow*) self);
	g_object_unref (self);
	return result;
}

static void
bird_font_gtk_window_real_save (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	GThread* thread = NULL;
	GError* _inner_error0_ = NULL;
	self = (BirdFontGtkWindow*) base;
	bird_font_menu_tab_start_background_thread ();
	{
		GThread* _tmp0_ = NULL;
		GThread* _tmp1_;
		_tmp1_ = g_thread_try_new ("thread", _bird_font_gtk_window_saving_thread_gthread_func, g_object_ref (self), &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		thread = _tmp0_;
		_g_thread_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("GtkWindow.vala:499: %s", _tmp3_);
		_g_error_free0 (e);
	}
	__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;
	}
}

void*
bird_font_gtk_window_saving_thread (BirdFontGtkWindow* self)
{
	BirdFontFont* _tmp0_;
	BirdFontFont* _tmp1_;
	void* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = bird_font_bird_font_get_current_font ();
	_tmp1_ = _tmp0_;
	bird_font_font_save (_tmp1_);
	_g_object_unref0 (_tmp1_);
	bird_font_menu_tab_stop_background_thread ();
	bird_font_menu_tab_signal_file_saved ();
	result = NULL;
	return result;
}

static gpointer
_bird_font_gtk_window_background_image_thread_gthread_func (gpointer self)
{
	gpointer result;
	result = bird_font_gtk_window_background_image_thread ((BirdFontGtkWindow*) self);
	g_object_unref (self);
	return result;
}

static void
bird_font_gtk_window_real_load_background_image (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	GThread* thread = NULL;
	GError* _inner_error0_ = NULL;
	self = (BirdFontGtkWindow*) base;
	bird_font_menu_tab_start_background_thread ();
	{
		GThread* _tmp0_ = NULL;
		GThread* _tmp1_;
		_tmp1_ = g_thread_try_new ("thread", _bird_font_gtk_window_background_image_thread_gthread_func, g_object_ref (self), &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		thread = _tmp0_;
		_g_thread_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("GtkWindow.vala:518: %s", _tmp3_);
		_g_error_free0 (e);
	}
	__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;
	}
}

void*
bird_font_gtk_window_background_image_thread (BirdFontGtkWindow* self)
{
	void* result;
	g_return_val_if_fail (self != NULL, NULL);
	bird_font_background_tool_load_background_image ();
	bird_font_menu_tab_stop_background_thread ();
	result = NULL;
	return result;
}

static gboolean
bird_font_gtk_window_real_can_export (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	gboolean result;
	self = (BirdFontGtkWindow*) base;
	result = TRUE;
	return result;
}

static void
bird_font_gtk_window_real_set_cursor (BirdFontNativeWindow* base,
                                      gint visible)
{
	BirdFontGtkWindow * self;
	self = (BirdFontGtkWindow*) base;
}

static gdouble
bird_font_gtk_window_real_get_screen_scale (BirdFontNativeWindow* base)
{
	BirdFontGtkWindow * self;
	GdkScreen* screen = NULL;
	GdkScreen* _tmp0_;
	GdkScreen* _tmp1_;
	GdkScreen* current_screen = NULL;
	GdkScreen* _tmp2_;
	gdouble resolution = 0.0;
	gdouble reference_resolution = 0.0;
	gdouble fractional_scale = 0.0;
	gint scale_factor = 0;
	gdouble result;
	self = (BirdFontGtkWindow*) base;
	_tmp0_ = gdk_screen_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	screen = _tmp1_;
	g_return_val_if_fail (screen != NULL, 1);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (screen, gdk_screen_get_type (), GdkScreen));
	current_screen = _tmp2_;
	resolution = gdk_screen_get_resolution (current_screen);
	reference_resolution = 96.0;
	fractional_scale = resolution / reference_resolution;
	scale_factor = gtk_widget_get_scale_factor ((GtkWidget*) self);
	result = scale_factor * fractional_scale;
	_g_object_unref0 (current_screen);
	_g_object_unref0 (screen);
	return result;
}

static void
bird_font_gtk_window_class_init (BirdFontGtkWindowClass * klass,
                                 gpointer klass_data)
{
	bird_font_gtk_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontGtkWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_gtk_window_finalize;
}

static void
bird_font_gtk_window_bird_font_native_window_interface_init (BirdFontNativeWindowIface * iface,
                                                             gpointer iface_data)
{
	bird_font_gtk_window_bird_font_native_window_parent_iface = g_type_interface_peek_parent (iface);
	iface->font_loaded = (void (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_font_loaded;
	iface->get_clipboard_data = (gchar* (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_get_clipboard_data;
	iface->set_inkscape_clipboard = (void (*) (BirdFontNativeWindow*, const gchar*)) bird_font_gtk_window_real_set_inkscape_clipboard;
	iface->set_clipboard_text = (void (*) (BirdFontNativeWindow*, const gchar*)) bird_font_gtk_window_real_set_clipboard_text;
	iface->get_clipboard_text = (gchar* (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_get_clipboard_text;
	iface->set_clipboard = (void (*) (BirdFontNativeWindow*, const gchar*)) bird_font_gtk_window_real_set_clipboard;
	iface->update_window_size = (void (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_update_window_size;
	iface->quit = (void (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_quit;
	iface->file_chooser = (void (*) (BirdFontNativeWindow*, const gchar*, BirdFontFileChooser*, guint)) bird_font_gtk_window_real_file_chooser;
	iface->convert_to_png = (gboolean (*) (BirdFontNativeWindow*, const gchar*, const gchar*)) bird_font_gtk_window_real_convert_to_png;
	iface->run_background_thread = (void (*) (BirdFontNativeWindow*, BirdFontTask*)) bird_font_gtk_window_real_run_background_thread;
	iface->run_non_blocking_background_thread = (void (*) (BirdFontNativeWindow*, BirdFontTask*)) bird_font_gtk_window_real_run_non_blocking_background_thread;
	iface->export_font = (void (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_export_font;
	iface->load = (void (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_load;
	iface->save = (void (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_save;
	iface->load_background_image = (void (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_load_background_image;
	iface->can_export = (gboolean (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_can_export;
	iface->set_cursor = (void (*) (BirdFontNativeWindow*, gint)) bird_font_gtk_window_real_set_cursor;
	iface->get_screen_scale = (gdouble (*) (BirdFontNativeWindow*)) bird_font_gtk_window_real_get_screen_scale;
}

static void
bird_font_gtk_window_instance_init (BirdFontGtkWindow * self,
                                    gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	BirdFontTask* _tmp2_;
	self->priv = bird_font_gtk_window_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->clipboard_svg = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->inkscape_clipboard = _tmp1_;
	_tmp2_ = bird_font_task_new (_bird_font_gtk_window_idle_bird_font_task_runnable, NULL, NULL, FALSE);
	self->priv->background_task = _tmp2_;
}

static void
bird_font_gtk_window_finalize (GObject * obj)
{
	BirdFontGtkWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_GTK_WINDOW, BirdFontGtkWindow);
	_g_object_unref0 (self->priv->list_box);
	_g_object_unref0 (self->priv->canvas_box);
	_g_object_unref0 (self->priv->html_canvas);
	_g_object_unref0 (self->priv->html_box);
	_g_object_unref0 (self->priv->tab_box);
	_g_object_unref0 (self->priv->glyph_canvas_area);
	_g_object_unref0 (self->priv->clipboard);
	_g_free0 (self->priv->clipboard_svg);
	_g_free0 (self->priv->inkscape_clipboard);
	_g_object_unref0 (self->priv->toolbox);
	_g_object_unref0 (self->priv->background_task);
	G_OBJECT_CLASS (bird_font_gtk_window_parent_class)->finalize (obj);
}

static GType
bird_font_gtk_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontGtkWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_gtk_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontGtkWindow), 0, (GInstanceInitFunc) bird_font_gtk_window_instance_init, NULL };
	static const GInterfaceInfo bird_font_native_window_info = { (GInterfaceInitFunc) bird_font_gtk_window_bird_font_native_window_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType bird_font_gtk_window_type_id;
	bird_font_gtk_window_type_id = g_type_register_static (gtk_window_get_type (), "BirdFontGtkWindow", &g_define_type_info, 0);
	g_type_add_interface_static (bird_font_gtk_window_type_id, BIRD_FONT_TYPE_NATIVE_WINDOW, &bird_font_native_window_info);
	BirdFontGtkWindow_private_offset = g_type_add_instance_private (bird_font_gtk_window_type_id, sizeof (BirdFontGtkWindowPrivate));
	return bird_font_gtk_window_type_id;
}

GType
bird_font_gtk_window_get_type (void)
{
	static volatile gsize bird_font_gtk_window_type_id__once = 0;
	if (g_once_init_enter (&bird_font_gtk_window_type_id__once)) {
		GType bird_font_gtk_window_type_id;
		bird_font_gtk_window_type_id = bird_font_gtk_window_get_type_once ();
		g_once_init_leave (&bird_font_gtk_window_type_id__once, bird_font_gtk_window_type_id);
	}
	return bird_font_gtk_window_type_id__once;
}

static inline gpointer
bird_font_tabbar_canvas_get_instance_private (BirdFontTabbarCanvas* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontTabbarCanvas_private_offset);
}

static gboolean
__lambda21_ (BirdFontTabbarCanvas* self,
             GtkWidget* t,
             GdkEventMotion* e)
{
	GtkAllocation alloc = {0};
	BirdFontTabBar* _tmp0_;
	GtkAllocation _tmp1_ = {0};
	GtkAllocation _tmp2_;
	GtkAllocation _tmp3_;
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = self->priv->tabbar;
	bird_font_tab_bar_motion (_tmp0_, e->x, e->y);
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp1_);
	alloc = _tmp1_;
	_tmp2_ = alloc;
	_tmp3_ = alloc;
	gtk_widget_queue_draw_area ((GtkWidget*) self, 0, 0, _tmp2_.width, _tmp3_.height);
	result = TRUE;
	return result;
}

static gboolean
___lambda21__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                             GdkEventMotion* event,
                                             gpointer self)
{
	gboolean result;
	result = __lambda21_ ((BirdFontTabbarCanvas*) self, _sender, event);
	return result;
}

static gboolean
__lambda22_ (BirdFontTabbarCanvas* self,
             GtkWidget* t,
             GdkEventButton* e)
{
	GtkAllocation alloc = {0};
	GtkAllocation _tmp0_ = {0};
	BirdFontTabBar* _tmp1_;
	GtkAllocation _tmp2_;
	GtkAllocation _tmp3_;
	GtkAllocation _tmp4_;
	GtkAllocation _tmp5_;
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp0_);
	alloc = _tmp0_;
	bird_font_gtk_window_reset_modifier (e->state);
	_tmp1_ = self->priv->tabbar;
	_tmp2_ = alloc;
	_tmp3_ = alloc;
	bird_font_tab_bar_select_tab_click (_tmp1_, e->x, e->y, _tmp2_.width, _tmp3_.height);
	_tmp4_ = alloc;
	_tmp5_ = alloc;
	gtk_widget_queue_draw_area ((GtkWidget*) self, 0, 0, _tmp4_.width, _tmp5_.height);
	result = TRUE;
	return result;
}

static gboolean
___lambda22__gtk_widget_button_press_event (GtkWidget* _sender,
                                            GdkEventButton* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda22_ ((BirdFontTabbarCanvas*) self, _sender, event);
	return result;
}

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

static gboolean
__lambda23_ (BirdFontTabbarCanvas* self,
             GtkWidget* t,
             cairo_t* e)
{
	GtkAllocation alloc = {0};
	cairo_t* cr = NULL;
	cairo_t* _tmp0_;
	GtkAllocation _tmp1_ = {0};
	BirdFontTabBar* _tmp2_;
	GtkAllocation _tmp3_;
	GtkAllocation _tmp4_;
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = _cairo_reference0 (e);
	cr = _tmp0_;
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp1_);
	alloc = _tmp1_;
	_tmp2_ = self->priv->tabbar;
	_tmp3_ = alloc;
	_tmp4_ = alloc;
	bird_font_tab_bar_draw (_tmp2_, cr, _tmp3_.width, _tmp4_.height);
	result = TRUE;
	_cairo_destroy0 (cr);
	return result;
}

static gboolean
___lambda23__gtk_widget_draw (GtkWidget* _sender,
                              cairo_t* cr,
                              gpointer self)
{
	gboolean result;
	result = __lambda23_ ((BirdFontTabbarCanvas*) self, _sender, cr);
	return result;
}

static void
__lambda24_ (BirdFontTabbarCanvas* self,
             BirdFontTab* t)
{
	GtkAllocation alloc = {0};
	GtkAllocation _tmp0_ = {0};
	GtkAllocation _tmp1_;
	GtkAllocation _tmp2_;
	g_return_if_fail (t != NULL);
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp0_);
	alloc = _tmp0_;
	_tmp1_ = alloc;
	_tmp2_ = alloc;
	gtk_widget_queue_draw_area ((GtkWidget*) self, 0, 0, _tmp1_.width, _tmp2_.height);
}

static void
___lambda24__bird_font_tab_bar_signal_tab_selected (BirdFontTabBar* _sender,
                                                    BirdFontTab* selected_tab,
                                                    gpointer self)
{
	__lambda24_ ((BirdFontTabbarCanvas*) self, selected_tab);
}

static void
__lambda25_ (BirdFontTabbarCanvas* self,
             gint x,
             gint y,
             gint w,
             gint h)
{
	gtk_widget_queue_draw_area ((GtkWidget*) self, x, y, w, h);
}

static void
___lambda25__bird_font_tab_bar_redraw_tab_bar (BirdFontTabBar* _sender,
                                               gint x,
                                               gint y,
                                               gint w,
                                               gint h,
                                               gpointer self)
{
	__lambda25_ ((BirdFontTabbarCanvas*) self, x, y, w, h);
}

BirdFontTabbarCanvas*
bird_font_tabbar_canvas_construct (GType object_type,
                                   BirdFontTabBar* tb)
{
	BirdFontTabbarCanvas * self = NULL;
	BirdFontTabBar* _tmp0_;
	BirdFontTabBar* _tmp1_;
	BirdFontTabBar* _tmp2_;
	g_return_val_if_fail (tb != NULL, NULL);
	self = (BirdFontTabbarCanvas*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (tb);
	_g_object_unref0 (self->priv->tabbar);
	self->priv->tabbar = _tmp0_;
	gtk_widget_add_events ((GtkWidget*) self, (gint) ((GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK) | GDK_LEAVE_NOTIFY_MASK));
	g_signal_connect_object ((GtkWidget*) self, "motion-notify-event", (GCallback) ___lambda21__gtk_widget_motion_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) ___lambda22__gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "draw", (GCallback) ___lambda23__gtk_widget_draw, self, 0);
	_tmp1_ = self->priv->tabbar;
	g_signal_connect_object (_tmp1_, "signal-tab-selected", (GCallback) ___lambda24__bird_font_tab_bar_signal_tab_selected, self, 0);
	_tmp2_ = self->priv->tabbar;
	g_signal_connect_object (_tmp2_, "redraw-tab-bar", (GCallback) ___lambda25__bird_font_tab_bar_redraw_tab_bar, self, 0);
	gtk_widget_set_size_request ((GtkWidget*) self, 20, 38);
	return self;
}

BirdFontTabbarCanvas*
bird_font_tabbar_canvas_new (BirdFontTabBar* tb)
{
	return bird_font_tabbar_canvas_construct (BIRD_FONT_TYPE_TABBAR_CANVAS, tb);
}

static void
bird_font_tabbar_canvas_class_init (BirdFontTabbarCanvasClass * klass,
                                    gpointer klass_data)
{
	bird_font_tabbar_canvas_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontTabbarCanvas_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_tabbar_canvas_finalize;
}

static void
bird_font_tabbar_canvas_instance_init (BirdFontTabbarCanvas * self,
                                       gpointer klass)
{
	self->priv = bird_font_tabbar_canvas_get_instance_private (self);
}

static void
bird_font_tabbar_canvas_finalize (GObject * obj)
{
	BirdFontTabbarCanvas * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_TABBAR_CANVAS, BirdFontTabbarCanvas);
	_g_object_unref0 (self->priv->tabbar);
	G_OBJECT_CLASS (bird_font_tabbar_canvas_parent_class)->finalize (obj);
}

static GType
bird_font_tabbar_canvas_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontTabbarCanvasClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_tabbar_canvas_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontTabbarCanvas), 0, (GInstanceInitFunc) bird_font_tabbar_canvas_instance_init, NULL };
	GType bird_font_tabbar_canvas_type_id;
	bird_font_tabbar_canvas_type_id = g_type_register_static (gtk_drawing_area_get_type (), "BirdFontTabbarCanvas", &g_define_type_info, 0);
	BirdFontTabbarCanvas_private_offset = g_type_add_instance_private (bird_font_tabbar_canvas_type_id, sizeof (BirdFontTabbarCanvasPrivate));
	return bird_font_tabbar_canvas_type_id;
}

GType
bird_font_tabbar_canvas_get_type (void)
{
	static volatile gsize bird_font_tabbar_canvas_type_id__once = 0;
	if (g_once_init_enter (&bird_font_tabbar_canvas_type_id__once)) {
		GType bird_font_tabbar_canvas_type_id;
		bird_font_tabbar_canvas_type_id = bird_font_tabbar_canvas_get_type_once ();
		g_once_init_leave (&bird_font_tabbar_canvas_type_id__once, bird_font_tabbar_canvas_type_id);
	}
	return bird_font_tabbar_canvas_type_id__once;
}

static inline gpointer
bird_font_toolbox_canvas_get_instance_private (BirdFontToolboxCanvas* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontToolboxCanvas_private_offset);
}

static void
__lambda10_ (BirdFontToolboxCanvas* self)
{
	GtkAllocation allocation = {0};
	GtkAllocation _tmp0_ = {0};
	GtkAllocation _tmp1_;
	GtkAllocation _tmp2_;
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp0_);
	allocation = _tmp0_;
	_tmp1_ = allocation;
	bird_font_toolbox_allocation_width = _tmp1_.width;
	_tmp2_ = allocation;
	bird_font_toolbox_allocation_height = _tmp2_.height;
	bird_font_toolbox_redraw_tool_box ();
}

static void
___lambda10__gtk_widget_realize (GtkWidget* _sender,
                                 gpointer self)
{
	__lambda10_ ((BirdFontToolboxCanvas*) self);
}

static void
__lambda11_ (BirdFontToolboxCanvas* self,
             gint x,
             gint y,
             gint w,
             gint h)
{
	if (h < 0) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp0_ = g_strdup_printf ("%i", h);
		_tmp1_ = _tmp0_;
		_tmp2_ = g_strconcat ("Toolbox height is less than zero: ", _tmp1_, NULL);
		_tmp3_ = _tmp2_;
		g_warning ("GtkWindow.vala:618: %s", _tmp3_);
		_g_free0 (_tmp3_);
		_g_free0 (_tmp1_);
		return;
	}
	gtk_widget_queue_draw_area ((GtkWidget*) self, x, y, w, h);
}

static void
___lambda11__bird_font_toolbox_redraw (BirdFontToolbox* _sender,
                                       gint x,
                                       gint y,
                                       gint w,
                                       gint h,
                                       gpointer self)
{
	__lambda11_ ((BirdFontToolboxCanvas*) self, x, y, w, h);
}

static gboolean
__lambda12_ (BirdFontToolboxCanvas* self,
             GtkWidget* se,
             GdkEventButton* e)
{
	gboolean result;
	g_return_val_if_fail (se != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	if (e->type == GDK_2BUTTON_PRESS) {
		BirdFontToolbox* _tmp0_;
		_tmp0_ = self->priv->tb;
		bird_font_toolbox_double_click (_tmp0_, e->button, e->x, e->y);
	} else {
		BirdFontToolbox* _tmp1_;
		_tmp1_ = self->priv->tb;
		bird_font_toolbox_press (_tmp1_, e->button, e->x, e->y);
	}
	result = TRUE;
	return result;
}

static gboolean
___lambda12__gtk_widget_button_press_event (GtkWidget* _sender,
                                            GdkEventButton* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda12_ ((BirdFontToolboxCanvas*) self, _sender, event);
	return result;
}

static gboolean
__lambda13_ (BirdFontToolboxCanvas* self,
             GtkWidget* se,
             GdkEventButton* e)
{
	BirdFontToolbox* _tmp0_;
	gboolean result;
	g_return_val_if_fail (se != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = self->priv->tb;
	bird_font_toolbox_release (_tmp0_, e->button, e->x, e->y);
	result = TRUE;
	return result;
}

static gboolean
___lambda13__gtk_widget_button_release_event (GtkWidget* _sender,
                                              GdkEventButton* event,
                                              gpointer self)
{
	gboolean result;
	result = __lambda13_ ((BirdFontToolboxCanvas*) self, _sender, event);
	return result;
}

static gboolean
__lambda14_ (BirdFontToolboxCanvas* self,
             GtkWidget* sen,
             GdkEventMotion* e)
{
	BirdFontToolbox* _tmp0_;
	gboolean result;
	g_return_val_if_fail (sen != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = self->priv->tb;
	bird_font_toolbox_move (_tmp0_, e->x, e->y);
	result = TRUE;
	return result;
}

static gboolean
___lambda14__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                             GdkEventMotion* event,
                                             gpointer self)
{
	gboolean result;
	result = __lambda14_ ((BirdFontToolboxCanvas*) self, _sender, event);
	return result;
}

static gboolean
__lambda15_ (BirdFontToolboxCanvas* self,
             GtkWidget* t,
             cairo_t* e)
{
	GtkAllocation allocation = {0};
	GtkAllocation _tmp0_ = {0};
	cairo_t* cw = NULL;
	GdkWindow* _tmp1_;
	cairo_t* _tmp2_;
	GtkAllocation _tmp3_;
	GtkAllocation _tmp4_;
	BirdFontToolbox* _tmp5_;
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp0_);
	allocation = _tmp0_;
	_tmp1_ = gtk_widget_get_window ((GtkWidget*) self);
	_tmp2_ = gdk_cairo_create (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gdk_window_get_type (), GdkWindow));
	cw = _tmp2_;
	_tmp3_ = allocation;
	bird_font_toolbox_allocation_width = _tmp3_.width;
	_tmp4_ = allocation;
	bird_font_toolbox_allocation_height = _tmp4_.height;
	_tmp5_ = self->priv->tb;
	bird_font_toolbox_draw (_tmp5_, bird_font_toolbox_allocation_width, bird_font_toolbox_allocation_height, cw);
	result = TRUE;
	_cairo_destroy0 (cw);
	return result;
}

static gboolean
___lambda15__gtk_widget_draw (GtkWidget* _sender,
                              cairo_t* cr,
                              gpointer self)
{
	gboolean result;
	result = __lambda15_ ((BirdFontToolboxCanvas*) self, _sender, cr);
	return result;
}

static gboolean
__lambda16_ (BirdFontToolboxCanvas* self,
             GtkWidget* t,
             GdkEventScroll* e)
{
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	if (e->direction == GDK_SCROLL_UP) {
		BirdFontToolbox* _tmp0_;
		_tmp0_ = self->priv->tb;
		bird_font_toolbox_scroll_up (_tmp0_, e->x, e->y);
	} else {
		if (e->direction == GDK_SCROLL_DOWN) {
			BirdFontToolbox* _tmp1_;
			_tmp1_ = self->priv->tb;
			bird_font_toolbox_scroll_down (_tmp1_, e->x, e->y);
		}
	}
	result = TRUE;
	return result;
}

static gboolean
___lambda16__gtk_widget_scroll_event (GtkWidget* _sender,
                                      GdkEventScroll* event,
                                      gpointer self)
{
	gboolean result;
	result = __lambda16_ ((BirdFontToolboxCanvas*) self, _sender, event);
	return result;
}

static gboolean
__lambda17_ (BirdFontToolboxCanvas* self,
             GtkWidget* t,
             GdkEventCrossing* e)
{
	BirdFontToolbox* _tmp0_;
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = self->priv->tb;
	bird_font_toolbox_reset_active_tool (_tmp0_);
	result = TRUE;
	return result;
}

static gboolean
___lambda17__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                            GdkEventCrossing* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda17_ ((BirdFontToolboxCanvas*) self, _sender, event);
	return result;
}

BirdFontToolboxCanvas*
bird_font_toolbox_canvas_construct (GType object_type,
                                    BirdFontToolbox* toolbox)
{
	BirdFontToolboxCanvas * self = NULL;
	BirdFontToolbox* _tmp0_;
	BirdFontToolbox* _tmp1_;
	gint width = 0;
	g_return_val_if_fail (toolbox != NULL, NULL);
	self = (BirdFontToolboxCanvas*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (toolbox);
	_g_object_unref0 (self->priv->tb);
	self->priv->tb = _tmp0_;
	g_signal_connect_object ((GtkWidget*) self, "realize", (GCallback) ___lambda10__gtk_widget_realize, self, 0);
	_tmp1_ = self->priv->tb;
	g_signal_connect_object (_tmp1_, "redraw", (GCallback) ___lambda11__bird_font_toolbox_redraw, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) ___lambda12__gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-release-event", (GCallback) ___lambda13__gtk_widget_button_release_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "motion-notify-event", (GCallback) ___lambda14__gtk_widget_motion_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "draw", (GCallback) ___lambda15__gtk_widget_draw, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "scroll-event", (GCallback) ___lambda16__gtk_widget_scroll_event, self, 0);
	gtk_widget_add_events ((GtkWidget*) self, (gint) ((((GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK) | GDK_POINTER_MOTION_MASK) | GDK_LEAVE_NOTIFY_MASK) | GDK_SCROLL_MASK));
	width = 212;
	gtk_widget_set_size_request ((GtkWidget*) self, width, 100);
	g_signal_connect_object ((GtkWidget*) self, "leave-notify-event", (GCallback) ___lambda17__gtk_widget_leave_notify_event, self, 0);
	return self;
}

BirdFontToolboxCanvas*
bird_font_toolbox_canvas_new (BirdFontToolbox* toolbox)
{
	return bird_font_toolbox_canvas_construct (BIRD_FONT_TYPE_TOOLBOX_CANVAS, toolbox);
}

static void
bird_font_toolbox_canvas_class_init (BirdFontToolboxCanvasClass * klass,
                                     gpointer klass_data)
{
	bird_font_toolbox_canvas_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontToolboxCanvas_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_toolbox_canvas_finalize;
}

static void
bird_font_toolbox_canvas_instance_init (BirdFontToolboxCanvas * self,
                                        gpointer klass)
{
	self->priv = bird_font_toolbox_canvas_get_instance_private (self);
}

static void
bird_font_toolbox_canvas_finalize (GObject * obj)
{
	BirdFontToolboxCanvas * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_TOOLBOX_CANVAS, BirdFontToolboxCanvas);
	_g_object_unref0 (self->priv->tb);
	G_OBJECT_CLASS (bird_font_toolbox_canvas_parent_class)->finalize (obj);
}

static GType
bird_font_toolbox_canvas_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontToolboxCanvasClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_toolbox_canvas_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontToolboxCanvas), 0, (GInstanceInitFunc) bird_font_toolbox_canvas_instance_init, NULL };
	GType bird_font_toolbox_canvas_type_id;
	bird_font_toolbox_canvas_type_id = g_type_register_static (gtk_drawing_area_get_type (), "BirdFontToolboxCanvas", &g_define_type_info, 0);
	BirdFontToolboxCanvas_private_offset = g_type_add_instance_private (bird_font_toolbox_canvas_type_id, sizeof (BirdFontToolboxCanvasPrivate));
	return bird_font_toolbox_canvas_type_id;
}

GType
bird_font_toolbox_canvas_get_type (void)
{
	static volatile gsize bird_font_toolbox_canvas_type_id__once = 0;
	if (g_once_init_enter (&bird_font_toolbox_canvas_type_id__once)) {
		GType bird_font_toolbox_canvas_type_id;
		bird_font_toolbox_canvas_type_id = bird_font_toolbox_canvas_get_type_once ();
		g_once_init_leave (&bird_font_toolbox_canvas_type_id__once, bird_font_toolbox_canvas_type_id);
	}
	return bird_font_toolbox_canvas_type_id__once;
}

static inline gpointer
bird_font_glyph_canvas_area_get_instance_private (BirdFontGlyphCanvasArea* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontGlyphCanvasArea_private_offset);
}

static void
__lambda4_ (BirdFontGlyphCanvasArea* self,
            gint x,
            gint y,
            gint w,
            gint h)
{
	gtk_widget_queue_draw_area ((GtkWidget*) self, (gint) x, (gint) y, (gint) w, (gint) h);
}

static void
___lambda4__bird_font_glyph_canvas_signal_redraw_area (BirdFontGlyphCanvas* _sender,
                                                       gint x,
                                                       gint y,
                                                       gint w,
                                                       gint h,
                                                       gpointer self)
{
	__lambda4_ ((BirdFontGlyphCanvasArea*) self, x, y, w, h);
}

static gboolean
__lambda5_ (BirdFontGlyphCanvasArea* self,
            GtkWidget* t,
            cairo_t* e)
{
	GtkAllocation allocation = {0};
	GtkAllocation _tmp0_ = {0};
	BirdFontWidgetAllocation* _tmp1_;
	BirdFontWidgetAllocation* _tmp2_;
	GtkAllocation _tmp3_;
	BirdFontWidgetAllocation* _tmp4_;
	GtkAllocation _tmp5_;
	BirdFontWidgetAllocation* _tmp6_;
	GtkAllocation _tmp7_;
	BirdFontWidgetAllocation* _tmp8_;
	GtkAllocation _tmp9_;
	cairo_t* cw = NULL;
	cairo_t* _tmp10_;
	cairo_surface_t* s = NULL;
	cairo_surface_t* _tmp11_;
	BirdFontWidgetAllocation* _tmp12_;
	BirdFontWidgetAllocation* _tmp13_;
	cairo_surface_t* _tmp14_;
	cairo_t* c = NULL;
	cairo_t* _tmp15_;
	BirdFontWidgetAllocation* _tmp16_;
	cairo_surface_t* _tmp17_;
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	gtk_widget_get_allocation ((GtkWidget*) self, &_tmp0_);
	allocation = _tmp0_;
	_tmp1_ = bird_font_widget_allocation_new ();
	_g_object_unref0 (self->priv->alloc);
	self->priv->alloc = _tmp1_;
	_tmp2_ = self->priv->alloc;
	_tmp3_ = allocation;
	_tmp2_->width = _tmp3_.width;
	_tmp4_ = self->priv->alloc;
	_tmp5_ = allocation;
	_tmp4_->height = _tmp5_.height;
	_tmp6_ = self->priv->alloc;
	_tmp7_ = allocation;
	_tmp6_->x = _tmp7_.x;
	_tmp8_ = self->priv->alloc;
	_tmp9_ = allocation;
	_tmp8_->y = _tmp9_.y;
	_tmp10_ = _cairo_reference0 (e);
	cw = _tmp10_;
	_tmp11_ = cairo_get_target (cw);
	_tmp12_ = self->priv->alloc;
	_tmp13_ = self->priv->alloc;
	_tmp14_ = cairo_surface_create_similar (_tmp11_, CAIRO_CONTENT_COLOR_ALPHA, _tmp12_->width, _tmp13_->height);
	s = _tmp14_;
	_tmp15_ = cairo_create (s);
	c = _tmp15_;
	_tmp16_ = self->priv->alloc;
	bird_font_tab_content_draw (_tmp16_, c);
	cairo_save (cw);
	_tmp17_ = cairo_get_target (c);
	cairo_set_source_surface (cw, _tmp17_, (gdouble) 0, (gdouble) 0);
	cairo_paint (cw);
	cairo_restore (cw);
	result = TRUE;
	_cairo_destroy0 (c);
	_cairo_surface_destroy0 (s);
	_cairo_destroy0 (cw);
	return result;
}

static gboolean
___lambda5__gtk_widget_draw (GtkWidget* _sender,
                             cairo_t* cr,
                             gpointer self)
{
	gboolean result;
	result = __lambda5_ ((BirdFontGlyphCanvasArea*) self, _sender, cr);
	return result;
}

static gboolean
__lambda6_ (BirdFontGlyphCanvasArea* self,
            GtkWidget* t,
            GdkEventButton* e)
{
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	bird_font_gtk_window_reset_modifier (e->state);
	if (e->time < self->priv->last_press) {
		g_warning ("GtkWindow.vala:733: Discarding event.");
		result = TRUE;
		return result;
	}
	self->priv->last_press = e->time;
	if (e->type == GDK_BUTTON_PRESS) {
		bird_font_tab_content_button_press (e->button, e->x, e->y);
	} else {
		if (e->type == GDK_2BUTTON_PRESS) {
			bird_font_tab_content_double_click (e->button, e->x, e->y);
		}
	}
	result = TRUE;
	return result;
}

static gboolean
___lambda6__gtk_widget_button_press_event (GtkWidget* _sender,
                                           GdkEventButton* event,
                                           gpointer self)
{
	gboolean result;
	result = __lambda6_ ((BirdFontGlyphCanvasArea*) self, _sender, event);
	return result;
}

static gboolean
__lambda7_ (BirdFontGlyphCanvasArea* self,
            GtkWidget* t,
            GdkEventButton* e)
{
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	if (e->time < self->priv->last_release) {
		g_warning ("GtkWindow.vala:750: Discarding event.");
		result = TRUE;
		return result;
	}
	if (e->type == GDK_BUTTON_RELEASE) {
		bird_font_tab_content_button_release ((gint) e->button, e->x, e->y);
	}
	self->priv->last_release = e->time;
	result = TRUE;
	return result;
}

static gboolean
___lambda7__gtk_widget_button_release_event (GtkWidget* _sender,
                                             GdkEventButton* event,
                                             gpointer self)
{
	gboolean result;
	result = __lambda7_ ((BirdFontGlyphCanvasArea*) self, _sender, event);
	return result;
}

static gboolean
__lambda8_ (BirdFontGlyphCanvasArea* self,
            GtkWidget* t,
            GdkEventMotion* e)
{
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	bird_font_tab_content_motion_notify (e->x, e->y);
	result = TRUE;
	return result;
}

static gboolean
___lambda8__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                            GdkEventMotion* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda8_ ((BirdFontGlyphCanvasArea*) self, _sender, event);
	return result;
}

static gboolean
__lambda9_ (BirdFontGlyphCanvasArea* self,
            GtkWidget* t,
            GdkEventScroll* e)
{
	gboolean result;
	g_return_val_if_fail (t != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	if (e->direction == GDK_SCROLL_UP) {
		bird_font_tab_content_scroll_wheel_up (e->x, e->y);
	} else {
		if (e->direction == GDK_SCROLL_DOWN) {
			bird_font_tab_content_scroll_wheel_down (e->x, e->y);
		}
	}
	bird_font_tab_content_button_release (2, e->x, e->y);
	result = TRUE;
	return result;
}

static gboolean
___lambda9__gtk_widget_scroll_event (GtkWidget* _sender,
                                     GdkEventScroll* event,
                                     gpointer self)
{
	gboolean result;
	result = __lambda9_ ((BirdFontGlyphCanvasArea*) self, _sender, event);
	return result;
}

BirdFontGlyphCanvasArea*
bird_font_glyph_canvas_area_construct (GType object_type,
                                       BirdFontGlyphCanvas* gc)
{
	BirdFontGlyphCanvasArea * self = NULL;
	gint event_flags = 0;
	BirdFontGlyphCanvas* _tmp0_;
	BirdFontGlyphCanvas* _tmp1_;
	g_return_val_if_fail (gc != NULL, NULL);
	self = (BirdFontGlyphCanvasArea*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (gc);
	_g_object_unref0 (self->priv->glyph_canvas);
	self->priv->glyph_canvas = _tmp0_;
	event_flags = (gint) GDK_BUTTON_PRESS_MASK;
	event_flags |= (gint) GDK_BUTTON_RELEASE_MASK;
	event_flags |= (gint) GDK_POINTER_MOTION_MASK;
	event_flags |= (gint) GDK_LEAVE_NOTIFY_MASK;
	event_flags |= (gint) GDK_SCROLL_MASK;
	gtk_widget_add_events ((GtkWidget*) self, event_flags);
	_tmp1_ = self->priv->glyph_canvas;
	g_signal_connect_object (_tmp1_, "signal-redraw-area", (GCallback) ___lambda4__bird_font_glyph_canvas_signal_redraw_area, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "draw", (GCallback) ___lambda5__gtk_widget_draw, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) ___lambda6__gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-release-event", (GCallback) ___lambda7__gtk_widget_button_release_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "motion-notify-event", (GCallback) ___lambda8__gtk_widget_motion_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "scroll-event", (GCallback) ___lambda9__gtk_widget_scroll_event, self, 0);
	gtk_widget_set_can_focus ((GtkWidget*) self, TRUE);
	return self;
}

BirdFontGlyphCanvasArea*
bird_font_glyph_canvas_area_new (BirdFontGlyphCanvas* gc)
{
	return bird_font_glyph_canvas_area_construct (BIRD_FONT_TYPE_GLYPH_CANVAS_AREA, gc);
}

static void
bird_font_glyph_canvas_area_class_init (BirdFontGlyphCanvasAreaClass * klass,
                                        gpointer klass_data)
{
	bird_font_glyph_canvas_area_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontGlyphCanvasArea_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_glyph_canvas_area_finalize;
}

static void
bird_font_glyph_canvas_area_instance_init (BirdFontGlyphCanvasArea * self,
                                           gpointer klass)
{
	BirdFontWidgetAllocation* _tmp0_;
	self->priv = bird_font_glyph_canvas_area_get_instance_private (self);
	_tmp0_ = bird_font_widget_allocation_new ();
	self->priv->alloc = _tmp0_;
	self->priv->last_release = (guint32) 0;
	self->priv->last_press = (guint32) 0;
}

static void
bird_font_glyph_canvas_area_finalize (GObject * obj)
{
	BirdFontGlyphCanvasArea * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_GLYPH_CANVAS_AREA, BirdFontGlyphCanvasArea);
	_g_object_unref0 (self->priv->glyph_canvas);
	_g_object_unref0 (self->priv->alloc);
	G_OBJECT_CLASS (bird_font_glyph_canvas_area_parent_class)->finalize (obj);
}

static GType
bird_font_glyph_canvas_area_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontGlyphCanvasAreaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_glyph_canvas_area_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontGlyphCanvasArea), 0, (GInstanceInitFunc) bird_font_glyph_canvas_area_instance_init, NULL };
	GType bird_font_glyph_canvas_area_type_id;
	bird_font_glyph_canvas_area_type_id = g_type_register_static (gtk_drawing_area_get_type (), "BirdFontGlyphCanvasArea", &g_define_type_info, 0);
	BirdFontGlyphCanvasArea_private_offset = g_type_add_instance_private (bird_font_glyph_canvas_area_type_id, sizeof (BirdFontGlyphCanvasAreaPrivate));
	return bird_font_glyph_canvas_area_type_id;
}

GType
bird_font_glyph_canvas_area_get_type (void)
{
	static volatile gsize bird_font_glyph_canvas_area_type_id__once = 0;
	if (g_once_init_enter (&bird_font_glyph_canvas_area_type_id__once)) {
		GType bird_font_glyph_canvas_area_type_id;
		bird_font_glyph_canvas_area_type_id = bird_font_glyph_canvas_area_get_type_once ();
		g_once_init_leave (&bird_font_glyph_canvas_area_type_id__once, bird_font_glyph_canvas_area_type_id);
	}
	return bird_font_glyph_canvas_area_type_id__once;
}

