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

/*
Copyright (C) 2014 Johan Mattsson

This library is free software; you can redistribute it and/or modify 
it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation; either version 3 of the 
License, or (at your option) any later version.

This library 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 
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <cairo-gobject.h>
#include <glib-object.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	BIRD_FONT_BACKGROUND_TAB_0_PROPERTY,
	BIRD_FONT_BACKGROUND_TAB_NUM_PROPERTIES
};
static GParamSpec* bird_font_background_tab_properties[BIRD_FONT_BACKGROUND_TAB_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer bird_font_background_tab_parent_class = NULL;
static BirdFontBackgroundTab* bird_font_background_tab_singleton;
static BirdFontBackgroundTab* bird_font_background_tab_singleton = NULL;

static gchar* bird_font_background_tab_real_get_name (BirdFontFontDisplay* base);
static gchar* bird_font_background_tab_real_get_label (BirdFontFontDisplay* base);
static void bird_font_background_tab_real_selected_canvas (BirdFontFontDisplay* base);
static void bird_font_background_tab_real_draw (BirdFontFontDisplay* base,
                                         BirdFontWidgetAllocation* allocation,
                                         cairo_t* cr);
static void bird_font_background_tab_finalize (GObject * obj);
static GType bird_font_background_tab_get_type_once (void);

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

BirdFontBackgroundTab*
bird_font_background_tab_construct (GType object_type)
{
	BirdFontBackgroundTab * self = NULL;
	BirdFontBackgroundTab* _tmp0_;
	BirdFontToolbox* tools = NULL;
	BirdFontToolbox* _tmp1_;
	BirdFontZoomTool* z = NULL;
	BirdFontTool* _tmp2_;
	BirdFontLayer* _tmp3_;
	BirdFontLayer* _tmp4_;
	BirdFontLayer* _tmp5_;
	self = (BirdFontBackgroundTab*) bird_font_glyph_construct (object_type, "", (gunichar) '\0');
	_tmp0_ = _g_object_ref0 (self);
	_g_object_unref0 (bird_font_background_tab_singleton);
	bird_font_background_tab_singleton = _tmp0_;
	_tmp1_ = bird_font_main_window_get_toolbox ();
	tools = _tmp1_;
	_tmp2_ = bird_font_toolbox_get_tool (tools, "zoom_tool");
	z = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, BIRD_FONT_TYPE_ZOOM_TOOL, BirdFontZoomTool);
	bird_font_zoom_tool_store_current_view (z);
	_tmp3_ = ((BirdFontGlyph*) self)->layers;
	_tmp4_ = bird_font_layer_new ();
	_tmp5_ = _tmp4_;
	bird_font_layer_add_layer (_tmp3_, _tmp5_);
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (z);
	_g_object_unref0 (tools);
	return self;
}

BirdFontBackgroundTab*
bird_font_background_tab_new (void)
{
	return bird_font_background_tab_construct (BIRD_FONT_TYPE_BACKGROUND_TAB);
}

BirdFontBackgroundTab*
bird_font_background_tab_get_instance (void)
{
	BirdFontBackgroundTab* _tmp0_;
	BirdFontBackgroundTab* _tmp2_;
	BirdFontBackgroundTab* _tmp3_;
	BirdFontBackgroundTab* result;
	_tmp0_ = bird_font_background_tab_singleton;
	if (bird_font_is_null (_tmp0_)) {
		BirdFontBackgroundTab* _tmp1_;
		_tmp1_ = bird_font_background_tab_new ();
		_g_object_unref0 (bird_font_background_tab_singleton);
		bird_font_background_tab_singleton = _tmp1_;
	}
	_tmp2_ = bird_font_background_tab_singleton;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

static gchar*
bird_font_background_tab_real_get_name (BirdFontFontDisplay* base)
{
	BirdFontBackgroundTab * self;
	gchar* _tmp0_;
	gchar* result;
	self = (BirdFontBackgroundTab*) base;
	_tmp0_ = g_strdup ("Backgrounds");
	result = _tmp0_;
	return result;
}

static gchar*
bird_font_background_tab_real_get_label (BirdFontFontDisplay* base)
{
	BirdFontBackgroundTab * self;
	gchar* _tmp0_;
	gchar* result;
	self = (BirdFontBackgroundTab*) base;
	_tmp0_ = bird_font_t_ ("Background Image");
	result = _tmp0_;
	return result;
}

static void
bird_font_background_tab_real_selected_canvas (BirdFontFontDisplay* base)
{
	BirdFontBackgroundTab * self;
	BirdFontGlyphCanvas* canvas = NULL;
	BirdFontGlyphCanvas* _tmp0_;
	BirdFontGlyphCollection* gc = NULL;
	BirdFontGlyphCollection* _tmp1_;
	BirdFontGlyphMaster* master = NULL;
	BirdFontGlyphMaster* _tmp2_;
	BirdFontSpinButton* _tmp3_;
	self = (BirdFontBackgroundTab*) base;
	BIRD_FONT_FONT_DISPLAY_CLASS (bird_font_background_tab_parent_class)->selected_canvas ((BirdFontFontDisplay*) G_TYPE_CHECK_INSTANCE_CAST (self, BIRD_FONT_TYPE_GLYPH, BirdFontGlyph));
	_tmp0_ = bird_font_main_window_get_glyph_canvas ();
	canvas = _tmp0_;
	_tmp1_ = bird_font_glyph_collection_new ((gunichar) '\0', "");
	gc = _tmp1_;
	_tmp2_ = bird_font_glyph_master_new ();
	master = _tmp2_;
	bird_font_glyph_master_add_glyph (master, (BirdFontGlyph*) self);
	bird_font_glyph_collection_add_master (gc, master);
	bird_font_glyph_canvas_set_current_glyph_collection (canvas, gc, FALSE);
	_tmp3_ = bird_font_drawing_tools_background_scale;
	bird_font_tool_set_tool_visibility ((BirdFontTool*) _tmp3_, TRUE);
	bird_font_zoom_tool_zoom_full_background_image ();
	_g_object_unref0 (master);
	_g_object_unref0 (gc);
	_g_object_unref0 (canvas);
}

static void
bird_font_background_tab_real_draw (BirdFontFontDisplay* base,
                                    BirdFontWidgetAllocation* allocation,
                                    cairo_t* cr)
{
	BirdFontBackgroundTab * self;
	BirdFontTool* t = NULL;
	BirdFontBackgroundTools* _tmp0_;
	BirdFontBackgroundSelectionTool* _tmp1_;
	BirdFontTool* _tmp2_;
	self = (BirdFontBackgroundTab*) base;
	g_return_if_fail (allocation != NULL);
	g_return_if_fail (cr != NULL);
	BIRD_FONT_FONT_DISPLAY_CLASS (bird_font_background_tab_parent_class)->draw ((BirdFontFontDisplay*) G_TYPE_CHECK_INSTANCE_CAST (self, BIRD_FONT_TYPE_GLYPH, BirdFontGlyph), allocation, cr);
	_tmp0_ = bird_font_toolbox_background_tools;
	_tmp1_ = _tmp0_->select_background;
	_tmp2_ = _g_object_ref0 ((BirdFontTool*) _tmp1_);
	t = _tmp2_;
	g_signal_emit_by_name (t, "draw-action", t, cr, (BirdFontGlyph*) self);
	_g_object_unref0 (t);
}

static void
bird_font_background_tab_class_init (BirdFontBackgroundTabClass * klass,
                                     gpointer klass_data)
{
	bird_font_background_tab_parent_class = g_type_class_peek_parent (klass);
	((BirdFontFontDisplayClass *) klass)->get_name = (gchar* (*) (BirdFontFontDisplay*)) bird_font_background_tab_real_get_name;
	((BirdFontFontDisplayClass *) klass)->get_label = (gchar* (*) (BirdFontFontDisplay*)) bird_font_background_tab_real_get_label;
	((BirdFontFontDisplayClass *) klass)->selected_canvas = (void (*) (BirdFontFontDisplay*)) bird_font_background_tab_real_selected_canvas;
	((BirdFontFontDisplayClass *) klass)->draw = (void (*) (BirdFontFontDisplay*, BirdFontWidgetAllocation*, cairo_t*)) bird_font_background_tab_real_draw;
	G_OBJECT_CLASS (klass)->finalize = bird_font_background_tab_finalize;
}

static void
bird_font_background_tab_instance_init (BirdFontBackgroundTab * self,
                                        gpointer klass)
{
}

static void
bird_font_background_tab_finalize (GObject * obj)
{
	BirdFontBackgroundTab * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_BACKGROUND_TAB, BirdFontBackgroundTab);
	G_OBJECT_CLASS (bird_font_background_tab_parent_class)->finalize (obj);
}

static GType
bird_font_background_tab_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontBackgroundTabClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_background_tab_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontBackgroundTab), 0, (GInstanceInitFunc) bird_font_background_tab_instance_init, NULL };
	GType bird_font_background_tab_type_id;
	bird_font_background_tab_type_id = g_type_register_static (BIRD_FONT_TYPE_GLYPH, "BirdFontBackgroundTab", &g_define_type_info, 0);
	return bird_font_background_tab_type_id;
}

GType
bird_font_background_tab_get_type (void)
{
	static volatile gsize bird_font_background_tab_type_id__once = 0;
	if (g_once_init_enter (&bird_font_background_tab_type_id__once)) {
		GType bird_font_background_tab_type_id;
		bird_font_background_tab_type_id = bird_font_background_tab_get_type_once ();
		g_once_init_leave (&bird_font_background_tab_type_id__once, bird_font_background_tab_type_id);
	}
	return bird_font_background_tab_type_id__once;
}

