/* contacts-crop-dialog.c generated by valac 0.56.0, the Vala compiler
 * generated from contacts-crop-dialog.vala, do not modify */

/*
 * Copyright (C) 2018 Elias Entrup <elias-git@flump.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <cc-crop-area.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib.h>
#include <gdk/gdk.h>

#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 CONTACTS_TYPE_CROP_DIALOG (contacts_crop_dialog_get_type ())
#define CONTACTS_CROP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialog))
#define CONTACTS_CROP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialogClass))
#define CONTACTS_IS_CROP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_CROP_DIALOG))
#define CONTACTS_IS_CROP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_CROP_DIALOG))
#define CONTACTS_CROP_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialogClass))

typedef struct _ContactsCropDialog ContactsCropDialog;
typedef struct _ContactsCropDialogClass ContactsCropDialogClass;
typedef struct _ContactsCropDialogPrivate ContactsCropDialogPrivate;
enum  {
	CONTACTS_CROP_DIALOG_0_PROPERTY,
	CONTACTS_CROP_DIALOG_NUM_PROPERTIES
};
static GParamSpec* contacts_crop_dialog_properties[CONTACTS_CROP_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ContactsCropDialog {
	GtkDialog parent_instance;
	ContactsCropDialogPrivate * priv;
};

struct _ContactsCropDialogClass {
	GtkDialogClass parent_class;
};

struct _ContactsCropDialogPrivate {
	GtkBox* box;
	CcCropArea* crop_area;
};

static gint ContactsCropDialog_private_offset;
static gpointer contacts_crop_dialog_parent_class = NULL;

VALA_EXTERN GType contacts_crop_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ContactsCropDialog, g_object_unref)
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_new_for_pixbuf (GdkPixbuf* pixbuf,
                                                         GtkWindow* parent);
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_construct_for_pixbuf (GType object_type,
                                                               GdkPixbuf* pixbuf,
                                                               GtkWindow* parent);
VALA_EXTERN GdkPixbuf* contacts_crop_dialog_create_pixbuf (ContactsCropDialog* self);
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_new (void);
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_construct (GType object_type);
static GObject * contacts_crop_dialog_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void contacts_crop_dialog_finalize (GObject * obj);
static GType contacts_crop_dialog_get_type_once (void);

static inline gpointer
contacts_crop_dialog_get_instance_private (ContactsCropDialog* self)
{
	return G_STRUCT_MEMBER_P (self, ContactsCropDialog_private_offset);
}

ContactsCropDialog*
contacts_crop_dialog_construct_for_pixbuf (GType object_type,
                                           GdkPixbuf* pixbuf,
                                           GtkWindow* parent)
{
	ContactsCropDialog * self = NULL;
	CcCropArea* _tmp0_;
	GdkTexture* _tmp1_;
	GdkTexture* _tmp2_;
	g_return_val_if_fail (pixbuf != NULL, NULL);
	self = (ContactsCropDialog*) g_object_new (object_type, "use-header-bar", 1, "transient-for", parent, NULL);
	_tmp0_ = self->priv->crop_area;
	_tmp1_ = gdk_texture_new_for_pixbuf (pixbuf);
	_tmp2_ = _tmp1_;
	cc_crop_area_set_paintable (_tmp0_, (GdkPaintable*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	return self;
}

ContactsCropDialog*
contacts_crop_dialog_new_for_pixbuf (GdkPixbuf* pixbuf,
                                     GtkWindow* parent)
{
	return contacts_crop_dialog_construct_for_pixbuf (CONTACTS_TYPE_CROP_DIALOG, pixbuf, parent);
}

GdkPixbuf*
contacts_crop_dialog_create_pixbuf (ContactsCropDialog* self)
{
	CcCropArea* _tmp0_;
	GdkPixbuf* _tmp1_;
	GdkPixbuf* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->crop_area;
	_tmp1_ = cc_crop_area_create_pixbuf (_tmp0_);
	result = _tmp1_;
	return result;
}

ContactsCropDialog*
contacts_crop_dialog_construct (GType object_type)
{
	ContactsCropDialog * self = NULL;
	self = (ContactsCropDialog*) g_object_new (object_type, NULL);
	return self;
}

ContactsCropDialog*
contacts_crop_dialog_new (void)
{
	return contacts_crop_dialog_construct (CONTACTS_TYPE_CROP_DIALOG);
}

static GObject *
contacts_crop_dialog_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ContactsCropDialog * self;
	CcCropArea* _tmp0_;
	CcCropArea* _tmp1_;
	CcCropArea* _tmp2_;
	CcCropArea* _tmp3_;
	GtkBox* _tmp4_;
	CcCropArea* _tmp5_;
	parent_class = G_OBJECT_CLASS (contacts_crop_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialog);
	_tmp0_ = (CcCropArea*) cc_crop_area_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->crop_area);
	self->priv->crop_area = _tmp0_;
	_tmp1_ = self->priv->crop_area;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp1_, TRUE);
	_tmp2_ = self->priv->crop_area;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp2_, TRUE);
	_tmp3_ = self->priv->crop_area;
	cc_crop_area_set_min_size (_tmp3_, 48, 48);
	_tmp4_ = self->priv->box;
	_tmp5_ = self->priv->crop_area;
	gtk_box_append (_tmp4_, (GtkWidget*) _tmp5_);
	return obj;
}

static void
contacts_crop_dialog_class_init (ContactsCropDialogClass * klass,
                                 gpointer klass_data)
{
	contacts_crop_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ContactsCropDialog_private_offset);
	G_OBJECT_CLASS (klass)->constructor = contacts_crop_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = contacts_crop_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Contacts/ui/contacts-crop-dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "box", FALSE, ContactsCropDialog_private_offset + G_STRUCT_OFFSET (ContactsCropDialogPrivate, box));
}

static void
contacts_crop_dialog_instance_init (ContactsCropDialog * self,
                                    gpointer klass)
{
	self->priv = contacts_crop_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
contacts_crop_dialog_finalize (GObject * obj)
{
	ContactsCropDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialog);
	_g_object_unref0 (self->priv->crop_area);
	G_OBJECT_CLASS (contacts_crop_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
contacts_crop_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsCropDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_crop_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsCropDialog), 0, (GInstanceInitFunc) contacts_crop_dialog_instance_init, NULL };
	GType contacts_crop_dialog_type_id;
	contacts_crop_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "ContactsCropDialog", &g_define_type_info, 0);
	ContactsCropDialog_private_offset = g_type_add_instance_private (contacts_crop_dialog_type_id, sizeof (ContactsCropDialogPrivate));
	return contacts_crop_dialog_type_id;
}

GType
contacts_crop_dialog_get_type (void)
{
	static volatile gsize contacts_crop_dialog_type_id__once = 0;
	if (g_once_init_enter (&contacts_crop_dialog_type_id__once)) {
		GType contacts_crop_dialog_type_id;
		contacts_crop_dialog_type_id = contacts_crop_dialog_get_type_once ();
		g_once_init_leave (&contacts_crop_dialog_type_id__once, contacts_crop_dialog_type_id);
	}
	return contacts_crop_dialog_type_id__once;
}

