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

/*
* Copyright (c) 2011-2016 Felipe Escoto (https://github.com/Philip-Scott/Notes-up)
*
* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authored by: Felipe Escoto <felescoto95@hotmail.com>
*/

#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>
#include <granite.h>
#include <cairo-gobject.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gio/gio.h>

#define ENOTES_SIDEBAR_ITEM_RADIUS 16
#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 GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM (granite_widgets_source_list_patch_item_get_type ())
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM, GraniteWidgetsSourceListPatchItem))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM, GraniteWidgetsSourceListPatchItemClass))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_ITEM, GraniteWidgetsSourceListPatchItemClass))

typedef struct _GraniteWidgetsSourceListPatchItem GraniteWidgetsSourceListPatchItem;
typedef struct _GraniteWidgetsSourceListPatchItemClass GraniteWidgetsSourceListPatchItemClass;
typedef struct _GraniteWidgetsSourceListPatchItemPrivate GraniteWidgetsSourceListPatchItemPrivate;

#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM (granite_widgets_source_list_patch_expandable_item_get_type ())
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_EXPANDABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM, GraniteWidgetsSourceListPatchExpandableItem))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_EXPANDABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM, GraniteWidgetsSourceListPatchExpandableItemClass))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_IS_EXPANDABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_IS_EXPANDABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_EXPANDABLE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM, GraniteWidgetsSourceListPatchExpandableItemClass))

typedef struct _GraniteWidgetsSourceListPatchExpandableItem GraniteWidgetsSourceListPatchExpandableItem;
typedef struct _GraniteWidgetsSourceListPatchExpandableItemClass GraniteWidgetsSourceListPatchExpandableItemClass;
typedef struct _GraniteWidgetsSourceListPatchExpandableItemPrivate GraniteWidgetsSourceListPatchExpandableItemPrivate;

#define ENOTES_TYPE_SIDEBAR_ITEM (enotes_sidebar_item_get_type ())
#define ENOTES_SIDEBAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_SIDEBAR_ITEM, ENotesSidebarItem))
#define ENOTES_SIDEBAR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_SIDEBAR_ITEM, ENotesSidebarItemClass))
#define ENOTES_IS_SIDEBAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_SIDEBAR_ITEM))
#define ENOTES_IS_SIDEBAR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_SIDEBAR_ITEM))
#define ENOTES_SIDEBAR_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_SIDEBAR_ITEM, ENotesSidebarItemClass))

typedef struct _ENotesSidebarItem ENotesSidebarItem;
typedef struct _ENotesSidebarItemClass ENotesSidebarItemClass;
typedef struct _ENotesSidebarItemPrivate ENotesSidebarItemPrivate;
enum  {
	ENOTES_SIDEBAR_ITEM_0_PROPERTY,
	ENOTES_SIDEBAR_ITEM_NUM_PROPERTIES
};
static GParamSpec* enotes_sidebar_item_properties[ENOTES_SIDEBAR_ITEM_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))

struct _GraniteWidgetsSourceListPatchItem {
	GObject parent_instance;
	GraniteWidgetsSourceListPatchItemPrivate * priv;
	gboolean use_pango_style;
	gboolean force_visible;
};

struct _GraniteWidgetsSourceListPatchItemClass {
	GObjectClass parent_class;
	GtkMenu* (*get_context_menu) (GraniteWidgetsSourceListPatchItem* self);
	void (*edited) (GraniteWidgetsSourceListPatchItem* self, const gchar* new_name);
	void (*action_activated) (GraniteWidgetsSourceListPatchItem* self);
	void (*activated) (GraniteWidgetsSourceListPatchItem* self);
};

struct _GraniteWidgetsSourceListPatchExpandableItem {
	GraniteWidgetsSourceListPatchItem parent_instance;
	GraniteWidgetsSourceListPatchExpandableItemPrivate * priv;
};

struct _GraniteWidgetsSourceListPatchExpandableItemClass {
	GraniteWidgetsSourceListPatchItemClass parent_class;
	void (*toggled) (GraniteWidgetsSourceListPatchExpandableItem* self);
};

struct _ENotesSidebarItem {
	GraniteWidgetsSourceListPatchExpandableItem parent_instance;
	ENotesSidebarItemPrivate * priv;
};

struct _ENotesSidebarItemClass {
	GraniteWidgetsSourceListPatchExpandableItemClass parent_class;
};

static gpointer enotes_sidebar_item_parent_class = NULL;

VALA_EXTERN GType granite_widgets_source_list_patch_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GraniteWidgetsSourceListPatchItem, g_object_unref)
VALA_EXTERN GType granite_widgets_source_list_patch_expandable_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GraniteWidgetsSourceListPatchExpandableItem, g_object_unref)
VALA_EXTERN GType enotes_sidebar_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesSidebarItem, g_object_unref)
VALA_EXTERN void enotes_sidebar_item_set_color (ENotesSidebarItem* self,
                                    GdkRGBA* rgba);
VALA_EXTERN void granite_widgets_source_list_patch_item_set_icon (GraniteWidgetsSourceListPatchItem* self,
                                                      GIcon* value);
VALA_EXTERN ENotesSidebarItem* enotes_sidebar_item_new (void);
VALA_EXTERN ENotesSidebarItem* enotes_sidebar_item_construct (GType object_type);
VALA_EXTERN GraniteWidgetsSourceListPatchExpandableItem* granite_widgets_source_list_patch_expandable_item_new (const gchar* name);
VALA_EXTERN GraniteWidgetsSourceListPatchExpandableItem* granite_widgets_source_list_patch_expandable_item_construct (GType object_type,
                                                                                                          const gchar* name);
static GType enotes_sidebar_item_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gpointer
_cairo_reference0 (gpointer self)
{
	return self ? cairo_reference (self) : NULL;
}

void
enotes_sidebar_item_set_color (ENotesSidebarItem* self,
                               GdkRGBA* rgba)
{
	GdkRGBA _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (rgba != NULL);
	_tmp0_ = *rgba;
	if (_tmp0_.red > ((gdouble) -1)) {
		GraniteDrawingBufferSurface* surface = NULL;
		GraniteDrawingBufferSurface* _tmp1_;
		cairo_t* cr = NULL;
		GraniteDrawingBufferSurface* _tmp2_;
		cairo_t* _tmp3_;
		cairo_t* _tmp4_;
		cairo_t* _tmp5_;
		cairo_t* _tmp6_;
		GdkRGBA _tmp7_;
		GdkRGBA _tmp8_;
		GdkRGBA _tmp9_;
		cairo_t* _tmp10_;
		cairo_t* _tmp11_;
		cairo_t* _tmp12_;
		cairo_t* _tmp13_;
		cairo_t* _tmp14_;
		GdkRGBA _tmp15_;
		GdkRGBA _tmp16_;
		GdkRGBA _tmp17_;
		cairo_t* _tmp18_;
		GraniteDrawingBufferSurface* _tmp19_;
		GdkPixbuf* _tmp20_;
		GdkPixbuf* _tmp21_;
		_tmp1_ = granite_drawing_buffer_surface_new (ENOTES_SIDEBAR_ITEM_RADIUS, ENOTES_SIDEBAR_ITEM_RADIUS);
		surface = _tmp1_;
		_tmp2_ = surface;
		_tmp3_ = granite_drawing_buffer_surface_get_context (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = _cairo_reference0 (_tmp4_);
		cr = _tmp5_;
		_tmp6_ = cr;
		_tmp7_ = *rgba;
		_tmp8_ = *rgba;
		_tmp9_ = *rgba;
		cairo_set_source_rgba (_tmp6_, _tmp7_.red, _tmp8_.green, _tmp9_.blue, 0.5);
		_tmp10_ = cr;
		cairo_translate (_tmp10_, (gdouble) (ENOTES_SIDEBAR_ITEM_RADIUS / 2), (gdouble) (ENOTES_SIDEBAR_ITEM_RADIUS / 2));
		_tmp11_ = cr;
		cairo_arc (_tmp11_, (gdouble) 0, (gdouble) 0, (gdouble) ((ENOTES_SIDEBAR_ITEM_RADIUS / 2) - 2), (gdouble) 0, 2 * G_PI);
		_tmp12_ = cr;
		cairo_fill_preserve (_tmp12_);
		_tmp13_ = cr;
		cairo_set_line_width (_tmp13_, 1.3);
		_tmp14_ = cr;
		_tmp15_ = *rgba;
		_tmp16_ = *rgba;
		_tmp17_ = *rgba;
		cairo_set_source_rgb (_tmp14_, _tmp15_.red, _tmp16_.green, _tmp17_.blue);
		_tmp18_ = cr;
		cairo_stroke (_tmp18_);
		_tmp19_ = surface;
		_tmp20_ = granite_drawing_buffer_surface_load_to_pixbuf (_tmp19_);
		_tmp21_ = _tmp20_;
		granite_widgets_source_list_patch_item_set_icon ((GraniteWidgetsSourceListPatchItem*) self, (GIcon*) _tmp21_);
		_g_object_unref0 (_tmp21_);
		_cairo_destroy0 (cr);
		_g_object_unref0 (surface);
	}
}

ENotesSidebarItem*
enotes_sidebar_item_construct (GType object_type)
{
	ENotesSidebarItem * self = NULL;
	self = (ENotesSidebarItem*) granite_widgets_source_list_patch_expandable_item_construct (object_type, "");
	return self;
}

ENotesSidebarItem*
enotes_sidebar_item_new (void)
{
	return enotes_sidebar_item_construct (ENOTES_TYPE_SIDEBAR_ITEM);
}

static void
enotes_sidebar_item_class_init (ENotesSidebarItemClass * klass,
                                gpointer klass_data)
{
	enotes_sidebar_item_parent_class = g_type_class_peek_parent (klass);
}

static void
enotes_sidebar_item_instance_init (ENotesSidebarItem * self,
                                   gpointer klass)
{
}

static GType
enotes_sidebar_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ENotesSidebarItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) enotes_sidebar_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ENotesSidebarItem), 0, (GInstanceInitFunc) enotes_sidebar_item_instance_init, NULL };
	GType enotes_sidebar_item_type_id;
	enotes_sidebar_item_type_id = g_type_register_static (GRANITE_WIDGETS_SOURCE_LIST_PATCH_TYPE_EXPANDABLE_ITEM, "ENotesSidebarItem", &g_define_type_info, 0);
	return enotes_sidebar_item_type_id;
}

GType
enotes_sidebar_item_get_type (void)
{
	static volatile gsize enotes_sidebar_item_type_id__once = 0;
	if (g_once_init_enter (&enotes_sidebar_item_type_id__once)) {
		GType enotes_sidebar_item_type_id;
		enotes_sidebar_item_type_id = enotes_sidebar_item_get_type_once ();
		g_once_init_leave (&enotes_sidebar_item_type_id__once, enotes_sidebar_item_type_id);
	}
	return enotes_sidebar_item_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

