/* BookmarkButton.c generated by valac 0.56.19, the Vala compiler
 * generated from BookmarkButton.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 <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <granite.h>
#include <stdlib.h>
#include <string.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 ENOTES_TYPE_BOOKMARK_BUTTON (enotes_bookmark_button_get_type ())
#define ENOTES_BOOKMARK_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_BOOKMARK_BUTTON, ENotesBookmarkButton))
#define ENOTES_BOOKMARK_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_BOOKMARK_BUTTON, ENotesBookmarkButtonClass))
#define ENOTES_IS_BOOKMARK_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_BOOKMARK_BUTTON))
#define ENOTES_IS_BOOKMARK_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_BOOKMARK_BUTTON))
#define ENOTES_BOOKMARK_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_BOOKMARK_BUTTON, ENotesBookmarkButtonClass))

typedef struct _ENotesBookmarkButton ENotesBookmarkButton;
typedef struct _ENotesBookmarkButtonClass ENotesBookmarkButtonClass;
typedef struct _ENotesBookmarkButtonPrivate ENotesBookmarkButtonPrivate;

#define ENOTES_TYPE_PAGE (enotes_page_get_type ())
#define ENOTES_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_PAGE, ENotesPage))
#define ENOTES_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_PAGE, ENotesPageClass))
#define ENOTES_IS_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_PAGE))
#define ENOTES_IS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_PAGE))
#define ENOTES_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_PAGE, ENotesPageClass))

typedef struct _ENotesPage ENotesPage;
typedef struct _ENotesPageClass ENotesPageClass;
enum  {
	ENOTES_BOOKMARK_BUTTON_0_PROPERTY,
	ENOTES_BOOKMARK_BUTTON_NUM_PROPERTIES
};
static GParamSpec* enotes_bookmark_button_properties[ENOTES_BOOKMARK_BUTTON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_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;
#define _g_free0(var) (var = (g_free (var), NULL))
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;

#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_BOOKMARK_TABLE (enotes_bookmark_table_get_type ())
#define ENOTES_BOOKMARK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_BOOKMARK_TABLE, ENotesBookmarkTable))
#define ENOTES_BOOKMARK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_BOOKMARK_TABLE, ENotesBookmarkTableClass))
#define ENOTES_IS_BOOKMARK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_BOOKMARK_TABLE))
#define ENOTES_IS_BOOKMARK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_BOOKMARK_TABLE))
#define ENOTES_BOOKMARK_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_BOOKMARK_TABLE, ENotesBookmarkTableClass))

typedef struct _ENotesBookmarkTable ENotesBookmarkTable;
typedef struct _ENotesBookmarkTableClass ENotesBookmarkTableClass;
#define _database_table_unref0(var) ((var == NULL) ? NULL : (var = (database_table_unref (var), NULL)))
typedef struct _ENotesPagePrivate ENotesPagePrivate;

#define GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH (granite_widgets_source_list_patch_get_type ())
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH, GraniteWidgetsSourceListPatch))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH, GraniteWidgetsSourceListPatchClass))
#define GRANITE_WIDGETS_IS_SOURCE_LIST_PATCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH))
#define GRANITE_WIDGETS_IS_SOURCE_LIST_PATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH))
#define GRANITE_WIDGETS_SOURCE_LIST_PATCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRANITE_WIDGETS_TYPE_SOURCE_LIST_PATCH, GraniteWidgetsSourceListPatchClass))

typedef struct _GraniteWidgetsSourceListPatch GraniteWidgetsSourceListPatch;
typedef struct _GraniteWidgetsSourceListPatchClass GraniteWidgetsSourceListPatchClass;

#define ENOTES_TYPE_SIDEBAR (enotes_sidebar_get_type ())
#define ENOTES_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_SIDEBAR, ENotesSidebar))
#define ENOTES_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_SIDEBAR, ENotesSidebarClass))
#define ENOTES_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_SIDEBAR))
#define ENOTES_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_SIDEBAR))
#define ENOTES_SIDEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_SIDEBAR, ENotesSidebarClass))

typedef struct _ENotesSidebar ENotesSidebar;
typedef struct _ENotesSidebarClass ENotesSidebarClass;

struct _ENotesBookmarkButton {
	GtkButton parent_instance;
	ENotesBookmarkButtonPrivate * priv;
};

struct _ENotesBookmarkButtonClass {
	GtkButtonClass parent_class;
};

struct _ENotesBookmarkButtonPrivate {
	ENotesPage* current_page;
	GtkImage* pic;
};

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

struct _ENotesApplicationClass {
	GraniteApplicationClass parent_class;
};

struct _ENotesPage {
	GObject parent_instance;
	ENotesPagePrivate * priv;
	gint64 id;
	gint64 notebook_id;
	gchar* name;
	gchar* data;
	gchar* subtitle;
	gchar* html_cache;
	gint64 creation_date;
	gint64 modification_date;
	gboolean new_page;
	gboolean cache_changed;
	gchar* full_path;
};

struct _ENotesPageClass {
	GObjectClass parent_class;
};

static gint ENotesBookmarkButton_private_offset;
static gpointer enotes_bookmark_button_parent_class = NULL;
VALA_EXTERN ENotesApplication* enotes_app;

VALA_EXTERN GType enotes_bookmark_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesBookmarkButton, g_object_unref)
VALA_EXTERN GType enotes_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesPage, g_object_unref)
VALA_EXTERN ENotesBookmarkButton* enotes_bookmark_button_new (void);
VALA_EXTERN ENotesBookmarkButton* enotes_bookmark_button_construct (GType object_type);
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 __lambda52_ (ENotesBookmarkButton* self);
VALA_EXTERN ENotesPage* enotes_application_state_get_opened_page (ENotesApplicationState* self);
static void enotes_bookmark_button_set_starred (ENotesBookmarkButton* self,
                                         gboolean value);
static void enotes_bookmark_button_set_starred_from_current_page (ENotesBookmarkButton* self);
static void ___lambda52__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void _enotes_bookmark_button_set_starred_from_current_page_enotes_application_state_bookmark_changed (ENotesApplicationState* _sender,
                                                                                                      gpointer self);
static void __lambda53_ (ENotesBookmarkButton* self);
VALA_EXTERN void enotes_bookmark_button_main_action (ENotesBookmarkButton* self);
static void ___lambda53__gtk_button_clicked (GtkButton* _sender,
                                      gpointer 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_bookmark_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesBookmarkTable, database_table_unref)
VALA_EXTERN ENotesBookmarkTable* enotes_bookmark_table_get_instance (void);
VALA_EXTERN gboolean enotes_bookmark_table_is_bookmarked (ENotesBookmarkTable* self,
                                              ENotesPage* page);
VALA_EXTERN void enotes_bookmark_table_remove (ENotesBookmarkTable* self,
                                   gint64 page_id);
VALA_EXTERN void enotes_bookmark_table_add (ENotesBookmarkTable* self,
                                ENotesPage* page);
VALA_EXTERN GType granite_widgets_source_list_patch_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GraniteWidgetsSourceListPatch, g_object_unref)
VALA_EXTERN GType enotes_sidebar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesSidebar, g_object_unref)
VALA_EXTERN ENotesSidebar* enotes_sidebar_get_instance (void);
VALA_EXTERN void enotes_sidebar_load_bookmarks (ENotesSidebar* self);
static void enotes_bookmark_button_finalize (GObject * obj);
static GType enotes_bookmark_button_get_type_once (void);
static void _vala_enotes_bookmark_button_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
enotes_bookmark_button_get_instance_private (ENotesBookmarkButton* self)
{
	return G_STRUCT_MEMBER_P (self, ENotesBookmarkButton_private_offset);
}

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

static void
__lambda52_ (ENotesBookmarkButton* self)
{
	ENotesPage* page = NULL;
	ENotesApplication* _tmp0_;
	ENotesApplicationState* _tmp1_;
	ENotesPage* _tmp2_;
	ENotesPage* _tmp3_;
	ENotesPage* _tmp4_;
	ENotesPage* _tmp5_;
	ENotesPage* _tmp6_;
	ENotesPage* _tmp7_;
	_tmp0_ = enotes_app;
	_tmp1_ = _tmp0_->state;
	_tmp2_ = enotes_application_state_get_opened_page (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	page = _tmp4_;
	_tmp5_ = page;
	if (_tmp5_ == NULL) {
		gtk_widget_set_sensitive ((GtkWidget*) self, FALSE);
		enotes_bookmark_button_set_starred (self, FALSE);
		_g_object_unref0 (page);
		return;
	}
	gtk_widget_set_sensitive ((GtkWidget*) self, TRUE);
	_tmp6_ = page;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	_g_object_unref0 (self->priv->current_page);
	self->priv->current_page = _tmp7_;
	enotes_bookmark_button_set_starred_from_current_page (self);
	_g_object_unref0 (page);
}

static void
___lambda52__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda52_ ((ENotesBookmarkButton*) self);
}

static void
_enotes_bookmark_button_set_starred_from_current_page_enotes_application_state_bookmark_changed (ENotesApplicationState* _sender,
                                                                                                 gpointer self)
{
	enotes_bookmark_button_set_starred_from_current_page ((ENotesBookmarkButton*) self);
}

static void
__lambda53_ (ENotesBookmarkButton* self)
{
	enotes_bookmark_button_main_action (self);
}

static void
___lambda53__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda53_ ((ENotesBookmarkButton*) self);
}

ENotesBookmarkButton*
enotes_bookmark_button_construct (GType object_type)
{
	ENotesBookmarkButton * self = NULL;
	GtkImage* _tmp0_;
	GtkImage* _tmp1_;
	ENotesApplication* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gchar* _tmp6_;
	gchar* _tmp7_;
	ENotesApplication* _tmp8_;
	ENotesApplicationState* _tmp9_;
	ENotesApplication* _tmp10_;
	ENotesApplicationState* _tmp11_;
	self = (ENotesBookmarkButton*) g_object_new (object_type, NULL);
	_tmp0_ = (GtkImage*) gtk_image_new_from_icon_name ("non-starred", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->pic);
	self->priv->pic = _tmp0_;
	_tmp1_ = self->priv->pic;
	gtk_button_set_image ((GtkButton*) self, (GtkWidget*) _tmp1_);
	g_object_set ((GtkWidget*) self, "expand", FALSE, NULL);
	gtk_widget_set_sensitive ((GtkWidget*) self, FALSE);
	gtk_widget_set_can_focus ((GtkWidget*) self, FALSE);
	gtk_widget_set_has_tooltip ((GtkWidget*) self, TRUE);
	_tmp2_ = enotes_app;
	_tmp4_ = _tmp3_ = gtk_application_get_accels_for_action ((GtkApplication*) _tmp2_, "win.bookmark-action");
	_tmp5_ = _tmp4_;
	_tmp5__length1 = _vala_array_length (_tmp3_);
	_tmp6_ = granite_markup_accel_tooltip (_tmp5_, (gint) _vala_array_length (_tmp3_), _ ("Bookmark page"));
	_tmp7_ = _tmp6_;
	gtk_widget_set_tooltip_markup ((GtkWidget*) self, _tmp7_);
	_g_free0 (_tmp7_);
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_free), NULL);
	_tmp8_ = enotes_app;
	_tmp9_ = _tmp8_->state;
	g_signal_connect_object ((GObject*) _tmp9_, "notify::opened-page", (GCallback) ___lambda52__g_object_notify, self, 0);
	_tmp10_ = enotes_app;
	_tmp11_ = _tmp10_->state;
	g_signal_connect_object (_tmp11_, "bookmark-changed", (GCallback) _enotes_bookmark_button_set_starred_from_current_page_enotes_application_state_bookmark_changed, self, 0);
	g_signal_connect_object ((GtkButton*) self, "clicked", (GCallback) ___lambda53__gtk_button_clicked, self, 0);
	return self;
}

ENotesBookmarkButton*
enotes_bookmark_button_new (void)
{
	return enotes_bookmark_button_construct (ENOTES_TYPE_BOOKMARK_BUTTON);
}

static void
enotes_bookmark_button_set_starred_from_current_page (ENotesBookmarkButton* self)
{
	ENotesBookmarkTable* _tmp0_;
	ENotesBookmarkTable* _tmp1_;
	ENotesPage* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = enotes_bookmark_table_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->current_page;
	enotes_bookmark_button_set_starred (self, enotes_bookmark_table_is_bookmarked (_tmp1_, _tmp2_));
	_database_table_unref0 (_tmp1_);
}

void
enotes_bookmark_button_main_action (ENotesBookmarkButton* self)
{
	ENotesBookmarkTable* _tmp0_;
	ENotesBookmarkTable* _tmp1_;
	ENotesPage* _tmp2_;
	gboolean _tmp3_;
	ENotesSidebar* _tmp10_;
	ENotesSidebar* _tmp11_;
	g_return_if_fail (self != NULL);
	_tmp0_ = enotes_bookmark_table_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->current_page;
	_tmp3_ = enotes_bookmark_table_is_bookmarked (_tmp1_, _tmp2_);
	_database_table_unref0 (_tmp1_);
	if (_tmp3_) {
		ENotesBookmarkTable* _tmp4_;
		ENotesBookmarkTable* _tmp5_;
		ENotesPage* _tmp6_;
		_tmp4_ = enotes_bookmark_table_get_instance ();
		_tmp5_ = _tmp4_;
		_tmp6_ = self->priv->current_page;
		enotes_bookmark_table_remove (_tmp5_, _tmp6_->id);
		_database_table_unref0 (_tmp5_);
	} else {
		ENotesBookmarkTable* _tmp7_;
		ENotesBookmarkTable* _tmp8_;
		ENotesPage* _tmp9_;
		_tmp7_ = enotes_bookmark_table_get_instance ();
		_tmp8_ = _tmp7_;
		_tmp9_ = self->priv->current_page;
		enotes_bookmark_table_add (_tmp8_, _tmp9_);
		_database_table_unref0 (_tmp8_);
	}
	_tmp10_ = enotes_sidebar_get_instance ();
	_tmp11_ = _tmp10_;
	enotes_sidebar_load_bookmarks (_tmp11_);
	_g_object_unref0 (_tmp11_);
	enotes_bookmark_button_set_starred_from_current_page (self);
}

static void
enotes_bookmark_button_set_starred (ENotesBookmarkButton* self,
                                    gboolean value)
{
	const gchar* _tmp0_ = NULL;
	GtkImage* _tmp1_;
	g_return_if_fail (self != NULL);
	if (value) {
		_tmp0_ = "starred";
	} else {
		_tmp0_ = "non-starred";
	}
	_tmp1_ = self->priv->pic;
	gtk_image_set_from_icon_name (_tmp1_, _tmp0_, (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
}

static void
enotes_bookmark_button_class_init (ENotesBookmarkButtonClass * klass,
                                   gpointer klass_data)
{
	enotes_bookmark_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ENotesBookmarkButton_private_offset);
	G_OBJECT_CLASS (klass)->set_property = _vala_enotes_bookmark_button_set_property;
	G_OBJECT_CLASS (klass)->finalize = enotes_bookmark_button_finalize;
}

static void
enotes_bookmark_button_instance_init (ENotesBookmarkButton * self,
                                      gpointer klass)
{
	self->priv = enotes_bookmark_button_get_instance_private (self);
}

static void
enotes_bookmark_button_finalize (GObject * obj)
{
	ENotesBookmarkButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ENOTES_TYPE_BOOKMARK_BUTTON, ENotesBookmarkButton);
	_g_object_unref0 (self->priv->current_page);
	_g_object_unref0 (self->priv->pic);
	G_OBJECT_CLASS (enotes_bookmark_button_parent_class)->finalize (obj);
}

static GType
enotes_bookmark_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ENotesBookmarkButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) enotes_bookmark_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ENotesBookmarkButton), 0, (GInstanceInitFunc) enotes_bookmark_button_instance_init, NULL };
	GType enotes_bookmark_button_type_id;
	enotes_bookmark_button_type_id = g_type_register_static (gtk_button_get_type (), "ENotesBookmarkButton", &g_define_type_info, 0);
	ENotesBookmarkButton_private_offset = g_type_add_instance_private (enotes_bookmark_button_type_id, sizeof (ENotesBookmarkButtonPrivate));
	return enotes_bookmark_button_type_id;
}

GType
enotes_bookmark_button_get_type (void)
{
	static volatile gsize enotes_bookmark_button_type_id__once = 0;
	if (g_once_init_enter (&enotes_bookmark_button_type_id__once)) {
		GType enotes_bookmark_button_type_id;
		enotes_bookmark_button_type_id = enotes_bookmark_button_get_type_once ();
		g_once_init_leave (&enotes_bookmark_button_type_id__once, enotes_bookmark_button_type_id);
	}
	return enotes_bookmark_button_type_id__once;
}

static void
_vala_enotes_bookmark_button_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	ENotesBookmarkButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ENOTES_TYPE_BOOKMARK_BUTTON, ENotesBookmarkButton);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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

