/* GlyphSelection.c generated by valac 0.56.17, the Vala compiler
 * generated from GlyphSelection.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 <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.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_GLYPH_SELECTION_0_PROPERTY,
	BIRD_FONT_GLYPH_SELECTION_NUM_PROPERTIES
};
static GParamSpec* bird_font_glyph_selection_properties[BIRD_FONT_GLYPH_SELECTION_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_source_unref0(var) ((var == NULL) ? NULL : (var = (g_source_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _bird_font_glyph_range_unref0(var) ((var == NULL) ? NULL : (var = (bird_font_glyph_range_unref (var), NULL)))
enum  {
	BIRD_FONT_GLYPH_SELECTION_SELECTED_GLYPH_SIGNAL,
	BIRD_FONT_GLYPH_SELECTION_NUM_SIGNALS
};
static guint bird_font_glyph_selection_signals[BIRD_FONT_GLYPH_SELECTION_NUM_SIGNALS] = {0};

static gpointer bird_font_glyph_selection_parent_class = NULL;

static void bird_font_glyph_selection_update_default_characterset (BirdFontGlyphSelection* self);
static void __lambda231_ (BirdFontGlyphSelection* self,
                   BirdFontGlyphCollection* gc);
static void ___lambda231__bird_font_overview_open_glyph_signal (BirdFontOverview* _sender,
                                                         BirdFontGlyphCollection* c,
                                                         gpointer self);
static gboolean __lambda316_ (BirdFontGlyphSelection* self);
static gboolean ___lambda316__gsource_func (gpointer self);
static GType bird_font_glyph_selection_get_type_once (void);

static void
__lambda231_ (BirdFontGlyphSelection* self,
              BirdFontGlyphCollection* gc)
{
	g_return_if_fail (gc != NULL);
	g_signal_emit (self, bird_font_glyph_selection_signals[BIRD_FONT_GLYPH_SELECTION_SELECTED_GLYPH_SIGNAL], 0, gc);
	bird_font_toolbox_redraw_tool_box ();
}

static void
___lambda231__bird_font_overview_open_glyph_signal (BirdFontOverview* _sender,
                                                    BirdFontGlyphCollection* c,
                                                    gpointer self)
{
	__lambda231_ ((BirdFontGlyphSelection*) self, c);
}

static gboolean
__lambda316_ (BirdFontGlyphSelection* self)
{
	gboolean result;
	bird_font_glyph_selection_update_default_characterset (self);
	result = FALSE;
	return result;
}

static gboolean
___lambda316__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda316_ ((BirdFontGlyphSelection*) self);
	return result;
}

BirdFontGlyphSelection*
bird_font_glyph_selection_construct (GType object_type)
{
	BirdFontGlyphSelection * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GSource* idle = NULL;
	GSource* _tmp2_;
	self = (BirdFontGlyphSelection*) bird_font_overview_construct (object_type, NULL, FALSE, FALSE);
	bird_font_glyph_selection_update_default_characterset (self);
	bird_font_overview_tools_update_overview_characterset ((BirdFontOverview*) self);
	bird_font_font_display_dirty_scrollbar = TRUE;
	g_signal_connect_object ((BirdFontOverview*) self, "open-glyph-signal", (GCallback) ___lambda231__bird_font_overview_open_glyph_signal, self, 0);
	_tmp0_ = bird_font_font_display_get_name ((BirdFontFontDisplay*) self);
	_tmp1_ = _tmp0_;
	bird_font_toolbox_set_toolbox_from_tab (_tmp1_, NULL);
	_g_free0 (_tmp1_);
	_tmp2_ = g_idle_source_new ();
	idle = _tmp2_;
	g_source_set_callback (idle, ___lambda316__gsource_func, g_object_ref (self), g_object_unref);
	g_source_attach (idle, NULL);
	_g_source_unref0 (idle);
	return self;
}

BirdFontGlyphSelection*
bird_font_glyph_selection_new (void)
{
	return bird_font_glyph_selection_construct (BIRD_FONT_TYPE_GLYPH_SELECTION);
}

static void
bird_font_glyph_selection_update_default_characterset (BirdFontGlyphSelection* self)
{
	BirdFontFont* _tmp0_;
	BirdFontFont* _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = bird_font_bird_font_get_current_font ();
	_tmp1_ = _tmp0_;
	_tmp2_ = bird_font_font_length (_tmp1_) > ((guint) 0);
	_g_object_unref0 (_tmp1_);
	if (_tmp2_) {
		bird_font_overview_display_all_available_glyphs ((BirdFontOverview*) self);
	} else {
		BirdFontGlyphRange* gr = NULL;
		BirdFontGlyphRange* _tmp3_;
		BirdFontGlyphRange* _tmp4_;
		BirdFontGlyphRange* _tmp5_;
		_tmp3_ = bird_font_glyph_range_new ();
		gr = _tmp3_;
		_tmp4_ = gr;
		bird_font_default_character_set_use_default_range (_tmp4_);
		_tmp5_ = gr;
		bird_font_overview_set_current_glyph_range ((BirdFontOverview*) self, _tmp5_);
		_bird_font_glyph_range_unref0 (gr);
	}
	bird_font_overview_update_item_list ((BirdFontOverview*) self);
}

static void
bird_font_glyph_selection_class_init (BirdFontGlyphSelectionClass * klass,
                                      gpointer klass_data)
{
	bird_font_glyph_selection_parent_class = g_type_class_peek_parent (klass);
	bird_font_glyph_selection_signals[BIRD_FONT_GLYPH_SELECTION_SELECTED_GLYPH_SIGNAL] = g_signal_new ("selected-glyph", BIRD_FONT_TYPE_GLYPH_SELECTION, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, BIRD_FONT_TYPE_GLYPH_COLLECTION);
}

static void
bird_font_glyph_selection_instance_init (BirdFontGlyphSelection * self,
                                         gpointer klass)
{
}

/** A tab for picking characters in the font. */
static GType
bird_font_glyph_selection_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontGlyphSelectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_glyph_selection_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontGlyphSelection), 0, (GInstanceInitFunc) bird_font_glyph_selection_instance_init, NULL };
	GType bird_font_glyph_selection_type_id;
	bird_font_glyph_selection_type_id = g_type_register_static (BIRD_FONT_TYPE_OVERVIEW, "BirdFontGlyphSelection", &g_define_type_info, 0);
	return bird_font_glyph_selection_type_id;
}

GType
bird_font_glyph_selection_get_type (void)
{
	static volatile gsize bird_font_glyph_selection_type_id__once = 0;
	if (g_once_init_enter (&bird_font_glyph_selection_type_id__once)) {
		GType bird_font_glyph_selection_type_id;
		bird_font_glyph_selection_type_id = bird_font_glyph_selection_get_type_once ();
		g_once_init_leave (&bird_font_glyph_selection_type_id__once, bird_font_glyph_selection_type_id);
	}
	return bird_font_glyph_selection_type_id__once;
}

