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

/*
* Copyright (c) 2019 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 <granite.h>
#include <glib/gi18n-lib.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
#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;

#define ENOTES_TYPE_TAG_ITEM (enotes_tag_item_get_type ())
#define ENOTES_TAG_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_TAG_ITEM, ENotesTagItem))
#define ENOTES_TAG_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_TAG_ITEM, ENotesTagItemClass))
#define ENOTES_IS_TAG_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_TAG_ITEM))
#define ENOTES_IS_TAG_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_TAG_ITEM))
#define ENOTES_TAG_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_TAG_ITEM, ENotesTagItemClass))

typedef struct _ENotesTagItem ENotesTagItem;
typedef struct _ENotesTagItemClass ENotesTagItemClass;
typedef struct _ENotesTagItemPrivate ENotesTagItemPrivate;

#define ENOTES_TYPE_TAG (enotes_tag_get_type ())
#define ENOTES_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_TAG, ENotesTag))
#define ENOTES_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_TAG, ENotesTagClass))
#define ENOTES_IS_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_TAG))
#define ENOTES_IS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_TAG))
#define ENOTES_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_TAG, ENotesTagClass))

typedef struct _ENotesTag ENotesTag;
typedef struct _ENotesTagClass ENotesTagClass;
enum  {
	ENOTES_TAG_ITEM_0_PROPERTY,
	ENOTES_TAG_ITEM_TAG_PROPERTY,
	ENOTES_TAG_ITEM_NUM_PROPERTIES
};
static GParamSpec* enotes_tag_item_properties[ENOTES_TAG_ITEM_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _ENotesTagPrivate ENotesTagPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_DATABASE_TABLE (database_table_get_type ())
#define DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATABASE_TABLE, DatabaseTable))
#define DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATABASE_TABLE, DatabaseTableClass))
#define IS_DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATABASE_TABLE))
#define IS_DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATABASE_TABLE))
#define DATABASE_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATABASE_TABLE, DatabaseTableClass))

typedef struct _DatabaseTable DatabaseTable;
typedef struct _DatabaseTableClass DatabaseTableClass;

#define ENOTES_TYPE_TAGS_TABLE (enotes_tags_table_get_type ())
#define ENOTES_TAGS_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_TAGS_TABLE, ENotesTagsTable))
#define ENOTES_TAGS_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_TAGS_TABLE, ENotesTagsTableClass))
#define ENOTES_IS_TAGS_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_TAGS_TABLE))
#define ENOTES_IS_TAGS_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_TAGS_TABLE))
#define ENOTES_TAGS_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_TAGS_TABLE, ENotesTagsTableClass))

typedef struct _ENotesTagsTable ENotesTagsTable;
typedef struct _ENotesTagsTableClass ENotesTagsTableClass;
#define _database_table_unref0(var) ((var == NULL) ? NULL : (var = (database_table_unref (var), NULL)))

#define ENOTES_TYPE_APPLICATION (enotes_application_get_type ())
#define ENOTES_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_APPLICATION, ENotesApplication))
#define ENOTES_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_APPLICATION, ENotesApplicationClass))
#define ENOTES_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_APPLICATION))
#define ENOTES_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_APPLICATION))
#define ENOTES_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_APPLICATION, ENotesApplicationClass))

typedef struct _ENotesApplication ENotesApplication;
typedef struct _ENotesApplicationClass ENotesApplicationClass;
typedef struct _ENotesApplicationPrivate ENotesApplicationPrivate;

#define ENOTES_APPLICATION_TYPE_STATE (enotes_application_state_get_type ())
#define ENOTES_APPLICATION_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_APPLICATION_TYPE_STATE, ENotesApplicationState))
#define ENOTES_APPLICATION_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_APPLICATION_TYPE_STATE, ENotesApplicationStateClass))
#define ENOTES_APPLICATION_IS_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_APPLICATION_TYPE_STATE))
#define ENOTES_APPLICATION_IS_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_APPLICATION_TYPE_STATE))
#define ENOTES_APPLICATION_STATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_APPLICATION_TYPE_STATE, ENotesApplicationStateClass))

typedef struct _ENotesApplicationState ENotesApplicationState;
typedef struct _ENotesApplicationStateClass ENotesApplicationStateClass;

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;
};

struct _ENotesTagItem {
	ENotesSidebarItem parent_instance;
	ENotesTagItemPrivate * priv;
};

struct _ENotesTagItemClass {
	ENotesSidebarItemClass parent_class;
};

struct _ENotesTagItemPrivate {
	ENotesTag* _tag;
	GtkMenu* menu;
	GtkMenuItem* remove_item;
};

struct _ENotesTag {
	GObject parent_instance;
	ENotesTagPrivate * priv;
	gint64 id;
	gchar* name;
	gchar* data;
};

struct _ENotesTagClass {
	GObjectClass parent_class;
};

struct _ENotesApplication {
	GraniteApplication parent_instance;
	ENotesApplicationPrivate * priv;
	gboolean running;
	ENotesApplicationState* state;
};

struct _ENotesApplicationClass {
	GraniteApplicationClass parent_class;
};

static gint ENotesTagItem_private_offset;
static gpointer enotes_tag_item_parent_class = NULL;
VALA_EXTERN ENotesApplication* enotes_app;

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 GType enotes_tag_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesTagItem, g_object_unref)
VALA_EXTERN GType enotes_tag_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesTag, g_object_unref)
VALA_EXTERN GtkMenu* granite_widgets_source_list_patch_item_get_context_menu (GraniteWidgetsSourceListPatchItem* self);
VALA_EXTERN ENotesTagItem* enotes_tag_item_new (ENotesTag* tag);
VALA_EXTERN ENotesTagItem* enotes_tag_item_construct (GType object_type,
                                          ENotesTag* tag);
VALA_EXTERN ENotesSidebarItem* enotes_sidebar_item_new (void);
VALA_EXTERN ENotesSidebarItem* enotes_sidebar_item_construct (GType object_type);
static void enotes_tag_item_set_tag (ENotesTagItem* self,
                              ENotesTag* value);
VALA_EXTERN void granite_widgets_source_list_patch_item_set_name (GraniteWidgetsSourceListPatchItem* self,
                                                      const gchar* value);
VALA_EXTERN void granite_widgets_source_list_patch_item_set_editable (GraniteWidgetsSourceListPatchItem* self,
                                                          gboolean value);
static void enotes_tag_item_setup_menu (ENotesTagItem* self);
static void __lambda68_ (ENotesTagItem* self,
                  const gchar* new_name);
VALA_EXTERN ENotesTag* enotes_tag_item_get_tag (ENotesTagItem* self);
VALA_EXTERN gpointer database_table_ref (gpointer instance);
VALA_EXTERN void database_table_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_database_table (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_database_table (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_database_table (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_database_table (const GValue* value);
VALA_EXTERN GType database_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DatabaseTable, database_table_unref)
VALA_EXTERN GType enotes_tags_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesTagsTable, database_table_unref)
VALA_EXTERN ENotesTagsTable* enotes_tags_table_get_instance (void);
VALA_EXTERN gboolean enotes_tags_table_save_tag (ENotesTagsTable* self,
                                     ENotesTag* tag);
VALA_EXTERN GType enotes_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesApplication, g_object_unref)
VALA_EXTERN GType enotes_application_state_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesApplicationState, g_object_unref)
static void ___lambda68__granite_widgets_source_list_patch_item_edited (GraniteWidgetsSourceListPatchItem* _sender,
                                                                 const gchar* new_name,
                                                                 gpointer self);
static void __lambda67_ (ENotesTagItem* self);
VALA_EXTERN void enotes_tags_table_delete_tag (ENotesTagsTable* self,
                                   ENotesTag* tag);
VALA_EXTERN void granite_widgets_source_list_patch_item_set_visible (GraniteWidgetsSourceListPatchItem* self,
                                                         gboolean value);
static void ___lambda67__gtk_menu_item_activate (GtkMenuItem* _sender,
                                          gpointer self);
static GtkMenu* enotes_tag_item_real_get_context_menu (GraniteWidgetsSourceListPatchItem* base);
static void enotes_tag_item_finalize (GObject * obj);
static GType enotes_tag_item_get_type_once (void);
static void _vala_enotes_tag_item_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_enotes_tag_item_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
enotes_tag_item_get_instance_private (ENotesTagItem* self)
{
	return G_STRUCT_MEMBER_P (self, ENotesTagItem_private_offset);
}

static void
__lambda68_ (ENotesTagItem* self,
             const gchar* new_name)
{
	gchar* old_name = NULL;
	ENotesTag* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	ENotesTag* _tmp3_;
	gchar* _tmp4_;
	gboolean _result_ = FALSE;
	ENotesTagsTable* _tmp5_;
	ENotesTagsTable* _tmp6_;
	ENotesTag* _tmp7_;
	gboolean _tmp8_;
	g_return_if_fail (new_name != NULL);
	_tmp0_ = self->priv->_tag;
	_tmp1_ = _tmp0_->name;
	_tmp2_ = g_strdup (_tmp1_);
	old_name = _tmp2_;
	_tmp3_ = self->priv->_tag;
	_tmp4_ = g_strdup (new_name);
	_g_free0 (_tmp3_->name);
	_tmp3_->name = _tmp4_;
	_tmp5_ = enotes_tags_table_get_instance ();
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->_tag;
	_tmp8_ = enotes_tags_table_save_tag (_tmp6_, _tmp7_);
	_database_table_unref0 (_tmp6_);
	_result_ = _tmp8_;
	if (_result_) {
		ENotesApplication* _tmp9_;
		ENotesApplicationState* _tmp10_;
		_tmp9_ = enotes_app;
		_tmp10_ = _tmp9_->state;
		g_signal_emit_by_name (_tmp10_, "tags-changed");
	} else {
		const gchar* _tmp11_;
		_tmp11_ = old_name;
		granite_widgets_source_list_patch_item_set_name ((GraniteWidgetsSourceListPatchItem*) self, _tmp11_);
	}
	_g_free0 (old_name);
}

static void
___lambda68__granite_widgets_source_list_patch_item_edited (GraniteWidgetsSourceListPatchItem* _sender,
                                                            const gchar* new_name,
                                                            gpointer self)
{
	__lambda68_ ((ENotesTagItem*) self, new_name);
}

ENotesTagItem*
enotes_tag_item_construct (GType object_type,
                           ENotesTag* tag)
{
	ENotesTagItem * self = NULL;
	const gchar* _tmp0_;
	g_return_val_if_fail (tag != NULL, NULL);
	self = (ENotesTagItem*) enotes_sidebar_item_construct (object_type);
	enotes_tag_item_set_tag (self, tag);
	_tmp0_ = tag->name;
	granite_widgets_source_list_patch_item_set_name ((GraniteWidgetsSourceListPatchItem*) self, _tmp0_);
	granite_widgets_source_list_patch_item_set_editable ((GraniteWidgetsSourceListPatchItem*) self, TRUE);
	enotes_tag_item_setup_menu (self);
	g_signal_connect_object ((GraniteWidgetsSourceListPatchItem*) self, "edited", (GCallback) ___lambda68__granite_widgets_source_list_patch_item_edited, self, 0);
	return self;
}

ENotesTagItem*
enotes_tag_item_new (ENotesTag* tag)
{
	return enotes_tag_item_construct (ENOTES_TYPE_TAG_ITEM, tag);
}

static void
__lambda67_ (ENotesTagItem* self)
{
	ENotesTagsTable* _tmp0_;
	ENotesTagsTable* _tmp1_;
	ENotesTag* _tmp2_;
	ENotesApplication* _tmp3_;
	ENotesApplicationState* _tmp4_;
	_tmp0_ = enotes_tags_table_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->_tag;
	enotes_tags_table_delete_tag (_tmp1_, _tmp2_);
	_database_table_unref0 (_tmp1_);
	_tmp3_ = enotes_app;
	_tmp4_ = _tmp3_->state;
	g_signal_emit_by_name (_tmp4_, "tags-changed");
	granite_widgets_source_list_patch_item_set_visible ((GraniteWidgetsSourceListPatchItem*) self, FALSE);
}

static void
___lambda67__gtk_menu_item_activate (GtkMenuItem* _sender,
                                     gpointer self)
{
	__lambda67_ ((ENotesTagItem*) self);
}

static void
enotes_tag_item_setup_menu (ENotesTagItem* self)
{
	GtkMenu* _tmp0_;
	GtkMenuItem* _tmp1_;
	GtkMenuItem* _tmp2_;
	GtkMenu* _tmp3_;
	GtkMenuItem* _tmp4_;
	GtkMenu* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkMenu*) gtk_menu_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->menu);
	self->priv->menu = _tmp0_;
	_tmp1_ = (GtkMenuItem*) gtk_menu_item_new_with_label (_ ("Remove"));
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->remove_item);
	self->priv->remove_item = _tmp1_;
	_tmp2_ = self->priv->remove_item;
	g_signal_connect_object (_tmp2_, "activate", (GCallback) ___lambda67__gtk_menu_item_activate, self, 0);
	_tmp3_ = self->priv->menu;
	_tmp4_ = self->priv->remove_item;
	gtk_container_add ((GtkContainer*) _tmp3_, (GtkWidget*) _tmp4_);
	_tmp5_ = self->priv->menu;
	gtk_widget_show_all ((GtkWidget*) _tmp5_);
}

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

static GtkMenu*
enotes_tag_item_real_get_context_menu (GraniteWidgetsSourceListPatchItem* base)
{
	ENotesTagItem * self;
	GtkMenu* _tmp0_;
	GtkMenu* _tmp1_;
	GtkMenu* result;
	self = (ENotesTagItem*) base;
	_tmp0_ = self->priv->menu;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

ENotesTag*
enotes_tag_item_get_tag (ENotesTagItem* self)
{
	ENotesTag* result;
	ENotesTag* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_tag;
	result = _tmp0_;
	return result;
}

static void
enotes_tag_item_set_tag (ENotesTagItem* self,
                         ENotesTag* value)
{
	ENotesTag* old_value;
	g_return_if_fail (self != NULL);
	old_value = enotes_tag_item_get_tag (self);
	if (old_value != value) {
		ENotesTag* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_tag);
		self->priv->_tag = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, enotes_tag_item_properties[ENOTES_TAG_ITEM_TAG_PROPERTY]);
	}
}

static void
enotes_tag_item_class_init (ENotesTagItemClass * klass,
                            gpointer klass_data)
{
	enotes_tag_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ENotesTagItem_private_offset);
	((GraniteWidgetsSourceListPatchItemClass *) klass)->get_context_menu = (GtkMenu* (*) (GraniteWidgetsSourceListPatchItem*)) enotes_tag_item_real_get_context_menu;
	G_OBJECT_CLASS (klass)->get_property = _vala_enotes_tag_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_enotes_tag_item_set_property;
	G_OBJECT_CLASS (klass)->finalize = enotes_tag_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ENOTES_TAG_ITEM_TAG_PROPERTY, enotes_tag_item_properties[ENOTES_TAG_ITEM_TAG_PROPERTY] = g_param_spec_object ("tag", "tag", "tag", ENOTES_TYPE_TAG, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
enotes_tag_item_instance_init (ENotesTagItem * self,
                               gpointer klass)
{
	self->priv = enotes_tag_item_get_instance_private (self);
}

static void
enotes_tag_item_finalize (GObject * obj)
{
	ENotesTagItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ENOTES_TYPE_TAG_ITEM, ENotesTagItem);
	_g_object_unref0 (self->priv->_tag);
	_g_object_unref0 (self->priv->menu);
	_g_object_unref0 (self->priv->remove_item);
	G_OBJECT_CLASS (enotes_tag_item_parent_class)->finalize (obj);
}

static GType
enotes_tag_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ENotesTagItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) enotes_tag_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ENotesTagItem), 0, (GInstanceInitFunc) enotes_tag_item_instance_init, NULL };
	GType enotes_tag_item_type_id;
	enotes_tag_item_type_id = g_type_register_static (ENOTES_TYPE_SIDEBAR_ITEM, "ENotesTagItem", &g_define_type_info, 0);
	ENotesTagItem_private_offset = g_type_add_instance_private (enotes_tag_item_type_id, sizeof (ENotesTagItemPrivate));
	return enotes_tag_item_type_id;
}

GType
enotes_tag_item_get_type (void)
{
	static volatile gsize enotes_tag_item_type_id__once = 0;
	if (g_once_init_enter (&enotes_tag_item_type_id__once)) {
		GType enotes_tag_item_type_id;
		enotes_tag_item_type_id = enotes_tag_item_get_type_once ();
		g_once_init_leave (&enotes_tag_item_type_id__once, enotes_tag_item_type_id);
	}
	return enotes_tag_item_type_id__once;
}

static void
_vala_enotes_tag_item_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	ENotesTagItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ENOTES_TYPE_TAG_ITEM, ENotesTagItem);
	switch (property_id) {
		case ENOTES_TAG_ITEM_TAG_PROPERTY:
		g_value_set_object (value, enotes_tag_item_get_tag (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_enotes_tag_item_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	ENotesTagItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ENOTES_TYPE_TAG_ITEM, ENotesTagItem);
	switch (property_id) {
		case ENOTES_TAG_ITEM_TAG_PROPERTY:
		enotes_tag_item_set_tag (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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;
}

