/* conversation-list-cell-renderer.c generated by valac 0.56.3, the Vala compiler
 * generated from conversation-list-cell-renderer.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

#include "geary-client-43.0.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <cairo-gobject.h>
#include <gdk/gdk.h>
#include <glib-object.h>

enum  {
	CONVERSATION_LIST_CELL_RENDERER_0_PROPERTY,
	CONVERSATION_LIST_CELL_RENDERER_DATA_PROPERTY,
	CONVERSATION_LIST_CELL_RENDERER_NUM_PROPERTIES
};
static GParamSpec* conversation_list_cell_renderer_properties[CONVERSATION_LIST_CELL_RENDERER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ConversationListCellRendererPrivate {
	FormattedConversationData* _data;
};

static gint ConversationListCellRenderer_private_offset;
static gpointer conversation_list_cell_renderer_parent_class = NULL;
static FormattedConversationData* conversation_list_cell_renderer_example_data;
static FormattedConversationData* conversation_list_cell_renderer_example_data = NULL;
static gboolean conversation_list_cell_renderer_hover_selected;
static gboolean conversation_list_cell_renderer_hover_selected = FALSE;

static void conversation_list_cell_renderer_real_get_preferred_height (GtkCellRenderer* base,
                                                                GtkWidget* widget,
                                                                gint* minimum_size,
                                                                gint* natural_size);
static void conversation_list_cell_renderer_real_get_preferred_width (GtkCellRenderer* base,
                                                               GtkWidget* widget,
                                                               gint* minimum_size,
                                                               gint* natural_size);
static void conversation_list_cell_renderer_real_render (GtkCellRenderer* base,
                                                  cairo_t* ctx,
                                                  GtkWidget* widget,
                                                  GdkRectangle* background_area,
                                                  GdkRectangle* cell_area,
                                                  GtkCellRendererState flags);
static void conversation_list_cell_renderer_real_get_size (GtkCellRenderer* base,
                                                    GtkWidget* widget,
                                                    GdkRectangle* cell_area,
                                                    gint* x_offset,
                                                    gint* y_offset,
                                                    gint* width,
                                                    gint* height);
static void conversation_list_cell_renderer_finalize (GObject * obj);
static GType conversation_list_cell_renderer_get_type_once (void);
static void _vala_conversation_list_cell_renderer_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static void _vala_conversation_list_cell_renderer_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec);

static inline gpointer
conversation_list_cell_renderer_get_instance_private (ConversationListCellRenderer* self)
{
	return G_STRUCT_MEMBER_P (self, ConversationListCellRenderer_private_offset);
}

FormattedConversationData*
conversation_list_cell_renderer_get_data (ConversationListCellRenderer* self)
{
	FormattedConversationData* result;
	FormattedConversationData* _tmp0_;
	g_return_val_if_fail (IS_CONVERSATION_LIST_CELL_RENDERER (self), NULL);
	_tmp0_ = self->priv->_data;
	result = _tmp0_;
	return result;
}

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

void
conversation_list_cell_renderer_set_data (ConversationListCellRenderer* self,
                                          FormattedConversationData* value)
{
	FormattedConversationData* old_value;
	g_return_if_fail (IS_CONVERSATION_LIST_CELL_RENDERER (self));
	old_value = conversation_list_cell_renderer_get_data (self);
	if (old_value != value) {
		FormattedConversationData* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_data);
		self->priv->_data = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, conversation_list_cell_renderer_properties[CONVERSATION_LIST_CELL_RENDERER_DATA_PROPERTY]);
	}
}

ConversationListCellRenderer*
conversation_list_cell_renderer_construct (GType object_type)
{
	ConversationListCellRenderer * self = NULL;
	self = (ConversationListCellRenderer*) g_object_new (object_type, NULL);
	return self;
}

ConversationListCellRenderer*
conversation_list_cell_renderer_new (void)
{
	return conversation_list_cell_renderer_construct (TYPE_CONVERSATION_LIST_CELL_RENDERER);
}

static void
conversation_list_cell_renderer_real_get_preferred_height (GtkCellRenderer* base,
                                                           GtkWidget* widget,
                                                           gint* minimum_size,
                                                           gint* natural_size)
{
	ConversationListCellRenderer * self;
	gint _vala_minimum_size = 0;
	gint _vala_natural_size = 0;
	FormattedConversationData* _tmp0_;
	FormattedConversationData* _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_CONVERSATION_LIST_CELL_RENDERER, ConversationListCellRenderer);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_widget_get_type ()));
	_tmp0_ = conversation_list_cell_renderer_example_data;
	if (_tmp0_ == NULL) {
		conversation_list_cell_renderer_style_changed (widget);
	}
	_tmp1_ = conversation_list_cell_renderer_example_data;
	_vala_natural_size = formatted_conversation_data_get_height (_tmp1_);
	_vala_minimum_size = _vala_natural_size;
	if (minimum_size) {
		*minimum_size = _vala_minimum_size;
	}
	if (natural_size) {
		*natural_size = _vala_natural_size;
	}
}

static void
conversation_list_cell_renderer_real_get_preferred_width (GtkCellRenderer* base,
                                                          GtkWidget* widget,
                                                          gint* minimum_size,
                                                          gint* natural_size)
{
	ConversationListCellRenderer * self;
	gint _vala_minimum_size = 0;
	gint _vala_natural_size = 0;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_CONVERSATION_LIST_CELL_RENDERER, ConversationListCellRenderer);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_widget_get_type ()));
	_vala_natural_size = 1;
	_vala_minimum_size = _vala_natural_size;
	if (minimum_size) {
		*minimum_size = _vala_minimum_size;
	}
	if (natural_size) {
		*natural_size = _vala_natural_size;
	}
}

static void
conversation_list_cell_renderer_real_render (GtkCellRenderer* base,
                                             cairo_t* ctx,
                                             GtkWidget* widget,
                                             GdkRectangle* background_area,
                                             GdkRectangle* cell_area,
                                             GtkCellRendererState flags)
{
	ConversationListCellRenderer * self;
	FormattedConversationData* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_CONVERSATION_LIST_CELL_RENDERER, ConversationListCellRenderer);
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_widget_get_type ()));
	g_return_if_fail (background_area != NULL);
	g_return_if_fail (cell_area != NULL);
	_tmp0_ = self->priv->_data;
	if (_tmp0_ != NULL) {
		FormattedConversationData* _tmp1_;
		GdkRectangle _tmp2_;
		GdkRectangle _tmp3_;
		_tmp1_ = self->priv->_data;
		_tmp2_ = *background_area;
		_tmp3_ = *cell_area;
		formatted_conversation_data_render (_tmp1_, ctx, widget, &_tmp2_, &_tmp3_, flags, conversation_list_cell_renderer_hover_selected);
	}
}

void
conversation_list_cell_renderer_style_changed (GtkWidget* widget)
{
	ApplicationMainWindow* window = NULL;
	GtkWidget* _tmp0_;
	ApplicationMainWindow* _tmp1_;
	gboolean _tmp2_ = FALSE;
	ApplicationMainWindow* _tmp3_;
	FormattedConversationData* _tmp11_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_widget_get_type ()));
	_tmp0_ = gtk_widget_get_toplevel (widget);
	_tmp1_ = _g_object_ref0 (APPLICATION_IS_MAIN_WINDOW (_tmp0_) ? ((ApplicationMainWindow*) _tmp0_) : NULL);
	window = _tmp1_;
	_tmp3_ = window;
	if (_tmp3_ != NULL) {
		FormattedConversationData* _tmp4_;
		_tmp4_ = conversation_list_cell_renderer_example_data;
		_tmp2_ = _tmp4_ == NULL;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		ApplicationMainWindow* _tmp5_;
		ApplicationClient* _tmp6_;
		ApplicationClient* _tmp7_;
		ApplicationConfiguration* _tmp8_;
		ApplicationConfiguration* _tmp9_;
		FormattedConversationData* _tmp10_;
		_tmp5_ = window;
		_tmp6_ = application_main_window_get_application (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = application_client_get_config (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = formatted_conversation_data_new_create_example (_tmp9_);
		_g_object_unref0 (conversation_list_cell_renderer_example_data);
		conversation_list_cell_renderer_example_data = _tmp10_;
	}
	_tmp11_ = conversation_list_cell_renderer_example_data;
	formatted_conversation_data_calculate_sizes (_tmp11_, widget);
	_g_object_unref0 (window);
}

void
conversation_list_cell_renderer_set_hover_selected (gboolean hover)
{
	conversation_list_cell_renderer_hover_selected = hover;
}

static void
conversation_list_cell_renderer_real_get_size (GtkCellRenderer* base,
                                               GtkWidget* widget,
                                               GdkRectangle* cell_area,
                                               gint* x_offset,
                                               gint* y_offset,
                                               gint* width,
                                               gint* height)
{
	ConversationListCellRenderer * self;
	gint _vala_x_offset = 0;
	gint _vala_y_offset = 0;
	gint _vala_width = 0;
	gint _vala_height = 0;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_CONVERSATION_LIST_CELL_RENDERER, ConversationListCellRenderer);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_widget_get_type ()));
	_vala_x_offset = 0;
	_vala_y_offset = 0;
	_vala_width = 0;
	_vala_height = 0;
	if (x_offset) {
		*x_offset = _vala_x_offset;
	}
	if (y_offset) {
		*y_offset = _vala_y_offset;
	}
	if (width) {
		*width = _vala_width;
	}
	if (height) {
		*height = _vala_height;
	}
}

static void
conversation_list_cell_renderer_class_init (ConversationListCellRendererClass * klass,
                                            gpointer klass_data)
{
	conversation_list_cell_renderer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ConversationListCellRenderer_private_offset);
	((GtkCellRendererClass *) klass)->get_preferred_height = (void (*) (GtkCellRenderer*, GtkWidget*, gint*, gint*)) conversation_list_cell_renderer_real_get_preferred_height;
	((GtkCellRendererClass *) klass)->get_preferred_width = (void (*) (GtkCellRenderer*, GtkWidget*, gint*, gint*)) conversation_list_cell_renderer_real_get_preferred_width;
	((GtkCellRendererClass *) klass)->render = (void (*) (GtkCellRenderer*, cairo_t*, GtkWidget*, GdkRectangle*, GdkRectangle*, GtkCellRendererState)) conversation_list_cell_renderer_real_render;
	((GtkCellRendererClass *) klass)->get_size = (void (*) (GtkCellRenderer*, GtkWidget*, GdkRectangle*, gint*, gint*, gint*, gint*)) conversation_list_cell_renderer_real_get_size;
	G_OBJECT_CLASS (klass)->get_property = _vala_conversation_list_cell_renderer_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_conversation_list_cell_renderer_set_property;
	G_OBJECT_CLASS (klass)->finalize = conversation_list_cell_renderer_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONVERSATION_LIST_CELL_RENDERER_DATA_PROPERTY, conversation_list_cell_renderer_properties[CONVERSATION_LIST_CELL_RENDERER_DATA_PROPERTY] = g_param_spec_object ("data", "data", "data", TYPE_FORMATTED_CONVERSATION_DATA, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
conversation_list_cell_renderer_instance_init (ConversationListCellRenderer * self,
                                               gpointer klass)
{
	self->priv = conversation_list_cell_renderer_get_instance_private (self);
}

static void
conversation_list_cell_renderer_finalize (GObject * obj)
{
	ConversationListCellRenderer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CONVERSATION_LIST_CELL_RENDERER, ConversationListCellRenderer);
	_g_object_unref0 (conversation_list_cell_renderer_example_data);
	conversation_list_cell_renderer_example_data = NULL;
	_g_object_unref0 (self->priv->_data);
	G_OBJECT_CLASS (conversation_list_cell_renderer_parent_class)->finalize (obj);
}

static GType
conversation_list_cell_renderer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConversationListCellRendererClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) conversation_list_cell_renderer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConversationListCellRenderer), 0, (GInstanceInitFunc) conversation_list_cell_renderer_instance_init, NULL };
	GType conversation_list_cell_renderer_type_id;
	conversation_list_cell_renderer_type_id = g_type_register_static (gtk_cell_renderer_get_type (), "ConversationListCellRenderer", &g_define_type_info, 0);
	ConversationListCellRenderer_private_offset = g_type_add_instance_private (conversation_list_cell_renderer_type_id, sizeof (ConversationListCellRendererPrivate));
	return conversation_list_cell_renderer_type_id;
}

GType
conversation_list_cell_renderer_get_type (void)
{
	static volatile gsize conversation_list_cell_renderer_type_id__once = 0;
	if (g_once_init_enter (&conversation_list_cell_renderer_type_id__once)) {
		GType conversation_list_cell_renderer_type_id;
		conversation_list_cell_renderer_type_id = conversation_list_cell_renderer_get_type_once ();
		g_once_init_leave (&conversation_list_cell_renderer_type_id__once, conversation_list_cell_renderer_type_id);
	}
	return conversation_list_cell_renderer_type_id__once;
}

static void
_vala_conversation_list_cell_renderer_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	ConversationListCellRenderer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_CONVERSATION_LIST_CELL_RENDERER, ConversationListCellRenderer);
	switch (property_id) {
		case CONVERSATION_LIST_CELL_RENDERER_DATA_PROPERTY:
		g_value_set_object (value, conversation_list_cell_renderer_get_data (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_conversation_list_cell_renderer_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec)
{
	ConversationListCellRenderer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_CONVERSATION_LIST_CELL_RENDERER, ConversationListCellRenderer);
	switch (property_id) {
		case CONVERSATION_LIST_CELL_RENDERER_DATA_PROPERTY:
		conversation_list_cell_renderer_set_data (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

