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

/*
* Copyright 2019 elementary, Inc. (https://elementary.io)
*
* 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
*/

#include <granite-7.h>
#include <glib-object.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>

#define NOTIFICATIONS_MASKED_IMAGE_ICON_SIZE 40
#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 NOTIFICATIONS_TYPE_MASKED_IMAGE (notifications_masked_image_get_type ())
#define NOTIFICATIONS_MASKED_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NOTIFICATIONS_TYPE_MASKED_IMAGE, NotificationsMaskedImage))
#define NOTIFICATIONS_MASKED_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NOTIFICATIONS_TYPE_MASKED_IMAGE, NotificationsMaskedImageClass))
#define NOTIFICATIONS_IS_MASKED_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NOTIFICATIONS_TYPE_MASKED_IMAGE))
#define NOTIFICATIONS_IS_MASKED_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NOTIFICATIONS_TYPE_MASKED_IMAGE))
#define NOTIFICATIONS_MASKED_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NOTIFICATIONS_TYPE_MASKED_IMAGE, NotificationsMaskedImageClass))

typedef struct _NotificationsMaskedImage NotificationsMaskedImage;
typedef struct _NotificationsMaskedImageClass NotificationsMaskedImageClass;
typedef struct _NotificationsMaskedImagePrivate NotificationsMaskedImagePrivate;
enum  {
	NOTIFICATIONS_MASKED_IMAGE_0_PROPERTY,
	NOTIFICATIONS_MASKED_IMAGE_PIXBUF_PROPERTY,
	NOTIFICATIONS_MASKED_IMAGE_NUM_PROPERTIES
};
static GParamSpec* notifications_masked_image_properties[NOTIFICATIONS_MASKED_IMAGE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _NotificationsMaskedImage {
	GraniteBin parent_instance;
	NotificationsMaskedImagePrivate * priv;
};

struct _NotificationsMaskedImageClass {
	GraniteBinClass parent_class;
};

struct _NotificationsMaskedImagePrivate {
	GdkPixbuf* _pixbuf;
};

static gint NotificationsMaskedImage_private_offset;
static gpointer notifications_masked_image_parent_class = NULL;

VALA_EXTERN GType notifications_masked_image_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NotificationsMaskedImage, g_object_unref)
VALA_EXTERN NotificationsMaskedImage* notifications_masked_image_new (GdkPixbuf* pixbuf);
VALA_EXTERN NotificationsMaskedImage* notifications_masked_image_construct (GType object_type,
                                                                GdkPixbuf* pixbuf);
VALA_EXTERN GdkPixbuf* notifications_masked_image_get_pixbuf (NotificationsMaskedImage* self);
static void notifications_masked_image_set_pixbuf (NotificationsMaskedImage* self,
                                            GdkPixbuf* value);
static GObject * notifications_masked_image_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static void notifications_masked_image_finalize (GObject * obj);
static GType notifications_masked_image_get_type_once (void);
static void _vala_notifications_masked_image_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_notifications_masked_image_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);

static inline gpointer
notifications_masked_image_get_instance_private (NotificationsMaskedImage* self)
{
	return G_STRUCT_MEMBER_P (self, NotificationsMaskedImage_private_offset);
}

NotificationsMaskedImage*
notifications_masked_image_construct (GType object_type,
                                      GdkPixbuf* pixbuf)
{
	NotificationsMaskedImage * self = NULL;
	g_return_val_if_fail (pixbuf != NULL, NULL);
	self = (NotificationsMaskedImage*) g_object_new (object_type, "pixbuf", pixbuf, NULL);
	return self;
}

NotificationsMaskedImage*
notifications_masked_image_new (GdkPixbuf* pixbuf)
{
	return notifications_masked_image_construct (NOTIFICATIONS_TYPE_MASKED_IMAGE, pixbuf);
}

GdkPixbuf*
notifications_masked_image_get_pixbuf (NotificationsMaskedImage* self)
{
	GdkPixbuf* result;
	GdkPixbuf* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_pixbuf;
	result = _tmp0_;
	return result;
}

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

static void
notifications_masked_image_set_pixbuf (NotificationsMaskedImage* self,
                                       GdkPixbuf* value)
{
	GdkPixbuf* old_value;
	g_return_if_fail (self != NULL);
	old_value = notifications_masked_image_get_pixbuf (self);
	if (old_value != value) {
		GdkPixbuf* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_pixbuf);
		self->priv->_pixbuf = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, notifications_masked_image_properties[NOTIFICATIONS_MASKED_IMAGE_PIXBUF_PROPERTY]);
	}
}

static GObject *
notifications_masked_image_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	NotificationsMaskedImage * self;
	GtkImage* image = NULL;
	GdkPixbuf* _tmp0_;
	GdkTexture* _tmp1_;
	GtkImage* _tmp2_ = NULL;
	GtkImage* _tmp3_;
	parent_class = G_OBJECT_CLASS (notifications_masked_image_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTIFICATIONS_TYPE_MASKED_IMAGE, NotificationsMaskedImage);
	_tmp0_ = self->priv->_pixbuf;
	_tmp1_ = gdk_texture_new_for_pixbuf (_tmp0_);
	_tmp2_ = (GtkImage*) gtk_image_new ();
	g_object_set (_tmp2_, "paintable", (GdkPaintable*) _tmp1_, NULL);
	_g_object_unref0 (_tmp1_);
	gtk_image_set_pixel_size (_tmp2_, NOTIFICATIONS_MASKED_IMAGE_ICON_SIZE);
	g_object_ref_sink (_tmp2_);
	image = _tmp2_;
	gtk_widget_add_css_class ((GtkWidget*) self, GRANITE_CSS_CLASS_CARD);
	gtk_widget_add_css_class ((GtkWidget*) self, GRANITE_CSS_CLASS_CHECKERBOARD);
	gtk_widget_set_overflow ((GtkWidget*) self, GTK_OVERFLOW_HIDDEN);
	_tmp3_ = image;
	granite_bin_set_child ((GraniteBin*) self, (GtkWidget*) _tmp3_);
	_g_object_unref0 (image);
	return obj;
}

static void
notifications_masked_image_base_init (NotificationsMaskedImageClass * klass)
{
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "masked-image");
}

static void
notifications_masked_image_class_init (NotificationsMaskedImageClass * klass,
                                       gpointer klass_data)
{
	notifications_masked_image_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NotificationsMaskedImage_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_notifications_masked_image_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_notifications_masked_image_set_property;
	G_OBJECT_CLASS (klass)->constructor = notifications_masked_image_constructor;
	G_OBJECT_CLASS (klass)->finalize = notifications_masked_image_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), NOTIFICATIONS_MASKED_IMAGE_PIXBUF_PROPERTY, notifications_masked_image_properties[NOTIFICATIONS_MASKED_IMAGE_PIXBUF_PROPERTY] = g_param_spec_object ("pixbuf", "pixbuf", "pixbuf", gdk_pixbuf_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
notifications_masked_image_instance_init (NotificationsMaskedImage * self,
                                          gpointer klass)
{
	self->priv = notifications_masked_image_get_instance_private (self);
}

static void
notifications_masked_image_finalize (GObject * obj)
{
	NotificationsMaskedImage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTIFICATIONS_TYPE_MASKED_IMAGE, NotificationsMaskedImage);
	_g_object_unref0 (self->priv->_pixbuf);
	G_OBJECT_CLASS (notifications_masked_image_parent_class)->finalize (obj);
}

static GType
notifications_masked_image_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NotificationsMaskedImageClass), (GBaseInitFunc) notifications_masked_image_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) notifications_masked_image_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NotificationsMaskedImage), 0, (GInstanceInitFunc) notifications_masked_image_instance_init, NULL };
	GType notifications_masked_image_type_id;
	notifications_masked_image_type_id = g_type_register_static (GRANITE_TYPE_BIN, "NotificationsMaskedImage", &g_define_type_info, 0);
	NotificationsMaskedImage_private_offset = g_type_add_instance_private (notifications_masked_image_type_id, sizeof (NotificationsMaskedImagePrivate));
	return notifications_masked_image_type_id;
}

GType
notifications_masked_image_get_type (void)
{
	static volatile gsize notifications_masked_image_type_id__once = 0;
	if (g_once_init_enter (&notifications_masked_image_type_id__once)) {
		GType notifications_masked_image_type_id;
		notifications_masked_image_type_id = notifications_masked_image_get_type_once ();
		g_once_init_leave (&notifications_masked_image_type_id__once, notifications_masked_image_type_id);
	}
	return notifications_masked_image_type_id__once;
}

static void
_vala_notifications_masked_image_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	NotificationsMaskedImage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NOTIFICATIONS_TYPE_MASKED_IMAGE, NotificationsMaskedImage);
	switch (property_id) {
		case NOTIFICATIONS_MASKED_IMAGE_PIXBUF_PROPERTY:
		g_value_set_object (value, notifications_masked_image_get_pixbuf (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_notifications_masked_image_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	NotificationsMaskedImage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NOTIFICATIONS_TYPE_MASKED_IMAGE, NotificationsMaskedImage);
	switch (property_id) {
		case NOTIFICATIONS_MASKED_IMAGE_PIXBUF_PROPERTY:
		notifications_masked_image_set_pixbuf (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

