/* NewNotebookDialog.c generated by valac 0.56.19, the Vala compiler
 * generated from NewNotebookDialog.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 <gtk/gtk.h>
#include <glib-object.h>
#include <granite.h>
#include <glib.h>
#include <webkit2/webkit2.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdk.h>
#include <string.h>
#include <stdlib.h>
#include <float.h>
#include <math.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_NOTEBOOK_DIALOG (enotes_notebook_dialog_get_type ())
#define ENOTES_NOTEBOOK_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_NOTEBOOK_DIALOG, ENotesNotebookDialog))
#define ENOTES_NOTEBOOK_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_NOTEBOOK_DIALOG, ENotesNotebookDialogClass))
#define ENOTES_IS_NOTEBOOK_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_NOTEBOOK_DIALOG))
#define ENOTES_IS_NOTEBOOK_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_NOTEBOOK_DIALOG))
#define ENOTES_NOTEBOOK_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_NOTEBOOK_DIALOG, ENotesNotebookDialogClass))

typedef struct _ENotesNotebookDialog ENotesNotebookDialog;
typedef struct _ENotesNotebookDialogClass ENotesNotebookDialogClass;
typedef struct _ENotesNotebookDialogPrivate ENotesNotebookDialogPrivate;

#define ENOTES_TYPE_NOTEBOOK (enotes_notebook_get_type ())
#define ENOTES_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_NOTEBOOK, ENotesNotebook))
#define ENOTES_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_NOTEBOOK, ENotesNotebookClass))
#define ENOTES_IS_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_NOTEBOOK))
#define ENOTES_IS_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_NOTEBOOK))
#define ENOTES_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_NOTEBOOK, ENotesNotebookClass))

typedef struct _ENotesNotebook ENotesNotebook;
typedef struct _ENotesNotebookClass ENotesNotebookClass;
enum  {
	ENOTES_NOTEBOOK_DIALOG_0_PROPERTY,
	ENOTES_NOTEBOOK_DIALOG_NUM_PROPERTIES
};
static GParamSpec* enotes_notebook_dialog_properties[ENOTES_NOTEBOOK_DIALOG_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 ENOTES_TYPE_WINDOW (enotes_window_get_type ())
#define ENOTES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_WINDOW, ENotesWindow))
#define ENOTES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_WINDOW, ENotesWindowClass))
#define ENOTES_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_WINDOW))
#define ENOTES_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_WINDOW))
#define ENOTES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_WINDOW, ENotesWindowClass))

typedef struct _ENotesWindow ENotesWindow;
typedef struct _ENotesWindowClass ENotesWindowClass;

#define ENOTES_TYPE_VIEW_EDIT_STACK (enotes_view_edit_stack_get_type ())
#define ENOTES_VIEW_EDIT_STACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_VIEW_EDIT_STACK, ENotesViewEditStack))
#define ENOTES_VIEW_EDIT_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_VIEW_EDIT_STACK, ENotesViewEditStackClass))
#define ENOTES_IS_VIEW_EDIT_STACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_VIEW_EDIT_STACK))
#define ENOTES_IS_VIEW_EDIT_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_VIEW_EDIT_STACK))
#define ENOTES_VIEW_EDIT_STACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_VIEW_EDIT_STACK, ENotesViewEditStackClass))

typedef struct _ENotesViewEditStack ENotesViewEditStack;
typedef struct _ENotesViewEditStackClass ENotesViewEditStackClass;

#define ENOTES_TYPE_VIEWER (enotes_viewer_get_type ())
#define ENOTES_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_VIEWER, ENotesViewer))
#define ENOTES_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_VIEWER, ENotesViewerClass))
#define ENOTES_IS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_VIEWER))
#define ENOTES_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_VIEWER))
#define ENOTES_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_VIEWER, ENotesViewerClass))

typedef struct _ENotesViewer ENotesViewer;
typedef struct _ENotesViewerClass ENotesViewerClass;
typedef struct _ENotesNotebookPrivate ENotesNotebookPrivate;
#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_NOTEBOOK_TABLE (enotes_notebook_table_get_type ())
#define ENOTES_NOTEBOOK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_NOTEBOOK_TABLE, ENotesNotebookTable))
#define ENOTES_NOTEBOOK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_NOTEBOOK_TABLE, ENotesNotebookTableClass))
#define ENOTES_IS_NOTEBOOK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_NOTEBOOK_TABLE))
#define ENOTES_IS_NOTEBOOK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_NOTEBOOK_TABLE))
#define ENOTES_NOTEBOOK_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_NOTEBOOK_TABLE, ENotesNotebookTableClass))

typedef struct _ENotesNotebookTable ENotesNotebookTable;
typedef struct _ENotesNotebookTableClass ENotesNotebookTableClass;
#define _database_table_unref0(var) ((var == NULL) ? NULL : (var = (database_table_unref (var), NULL)))

#define ENOTES_TYPE_PAGE_TABLE (enotes_page_table_get_type ())
#define ENOTES_PAGE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ENOTES_TYPE_PAGE_TABLE, ENotesPageTable))
#define ENOTES_PAGE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ENOTES_TYPE_PAGE_TABLE, ENotesPageTableClass))
#define ENOTES_IS_PAGE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ENOTES_TYPE_PAGE_TABLE))
#define ENOTES_IS_PAGE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ENOTES_TYPE_PAGE_TABLE))
#define ENOTES_PAGE_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ENOTES_TYPE_PAGE_TABLE, ENotesPageTableClass))

typedef struct _ENotesPageTable ENotesPageTable;
typedef struct _ENotesPageTableClass ENotesPageTableClass;
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 _ENotesNotebookDialog {
	GtkDialog parent_instance;
	ENotesNotebookDialogPrivate * priv;
};

struct _ENotesNotebookDialogClass {
	GtkDialogClass parent_class;
};

struct _ENotesNotebookDialogPrivate {
	GtkStack* stack;
	GtkEntry* name_entry;
	GtkColorButton* color_button;
	GtkComboBox* style_box;
	GtkTextView* style_changes;
	GtkButton* create;
	ENotesNotebook* notebook;
	ENotesNotebook* parent_nb;
};

struct _ENotesNotebook {
	GObject parent_instance;
	ENotesNotebookPrivate * priv;
	gint64 id;
	gint64* parent_id;
	GdkRGBA rgb;
	gchar* name;
	gchar* css;
	gchar* stylesheet;
};

struct _ENotesNotebookClass {
	GObjectClass parent_class;
};

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

struct _ENotesApplicationClass {
	GraniteApplicationClass parent_class;
};

static gint ENotesNotebookDialog_private_offset;
static gpointer enotes_notebook_dialog_parent_class = NULL;
VALA_EXTERN ENotesApplication* enotes_app;
VALA_EXTERN gchar** enotes_style_loader_STYLES;
VALA_EXTERN gint enotes_style_loader_STYLES_length1;

VALA_EXTERN GType enotes_notebook_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesNotebookDialog, g_object_unref)
VALA_EXTERN GType enotes_notebook_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesNotebook, g_object_unref)
VALA_EXTERN ENotesNotebookDialog* enotes_notebook_dialog_new (ENotesNotebook* notebook);
VALA_EXTERN ENotesNotebookDialog* enotes_notebook_dialog_construct (GType object_type,
                                                        ENotesNotebook* notebook);
VALA_EXTERN GType enotes_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesApplication, g_object_unref)
VALA_EXTERN GType enotes_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesWindow, g_object_unref)
VALA_EXTERN ENotesWindow* enotes_application_get_app_window (ENotesApplication* self);
VALA_EXTERN void enotes_notebook_dialog_build_ui (ENotesNotebookDialog* self);
static void enotes_notebook_dialog_connect_signals (ENotesNotebookDialog* self);
static void enotes_notebook_dialog_load_data (ENotesNotebookDialog* self);
static void ___lambda59_ (ENotesNotebookDialog* self);
VALA_EXTERN GType enotes_view_edit_stack_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesViewEditStack, g_object_unref)
VALA_EXTERN ENotesViewEditStack* enotes_view_edit_stack_get_instance (void);
VALA_EXTERN GType enotes_viewer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesViewer, g_object_unref)
VALA_EXTERN ENotesViewer* enotes_view_edit_stack_get_viewer (ENotesViewEditStack* self);
VALA_EXTERN void enotes_viewer_reload_page (ENotesViewer* self);
static void ____lambda59__gtk_combo_box_changed (GtkComboBox* _sender,
                                          gpointer self);
VALA_EXTERN ENotesNotebookDialog* enotes_notebook_dialog_new_new_subnotebook (ENotesNotebook* parent);
VALA_EXTERN ENotesNotebookDialog* enotes_notebook_dialog_construct_new_subnotebook (GType object_type,
                                                                        ENotesNotebook* parent);
static gint enotes_notebook_dialog_get_notebook_style (ENotesNotebookDialog* self,
                                                ENotesNotebook* notebook);
static void enotes_notebook_dialog_make_store (ENotesNotebookDialog* self);
static GtkGrid* enotes_notebook_dialog_viewer_grid (ENotesNotebookDialog* self);
static void __lambda57_ (ENotesNotebookDialog* self,
                  gint ID);
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_notebook_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesNotebookTable, database_table_unref)
VALA_EXTERN ENotesNotebookTable* enotes_notebook_table_get_instance (void);
VALA_EXTERN gint64 enotes_notebook_table_new_notebook (ENotesNotebookTable* self,
                                           gint64 parent,
                                           const gchar* name,
                                           GdkRGBA* rgb,
                                           const gchar* css,
                                           const gchar* stylesheet);
VALA_EXTERN GType enotes_page_table_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesPageTable, database_table_unref)
VALA_EXTERN ENotesPageTable* enotes_page_table_get_instance (void);
VALA_EXTERN void enotes_page_table_clear_cache_on (ENotesPageTable* self,
                                       gint64 id);
VALA_EXTERN void enotes_notebook_table_save_notebook (ENotesNotebookTable* self,
                                          gint64 notebook_id,
                                          const gchar* name,
                                          GdkRGBA* rgb,
                                          const gchar* css,
                                          const gchar* stylesheet);
VALA_EXTERN GType enotes_application_state_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ENotesApplicationState, g_object_unref)
static void ___lambda57__gtk_dialog_response (GtkDialog* _sender,
                                       gint response_id,
                                       gpointer self);
static void __lambda58_ (ENotesNotebookDialog* self);
static void ___lambda58__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void enotes_notebook_dialog_finalize (GObject * obj);
static GType enotes_notebook_dialog_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
enotes_notebook_dialog_get_instance_private (ENotesNotebookDialog* self)
{
	return G_STRUCT_MEMBER_P (self, ENotesNotebookDialog_private_offset);
}

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

static void
___lambda59_ (ENotesNotebookDialog* self)
{
	ENotesViewEditStack* _tmp0_;
	ENotesViewEditStack* _tmp1_;
	ENotesViewer* _tmp2_;
	ENotesViewer* _tmp3_;
	_tmp0_ = enotes_view_edit_stack_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = enotes_view_edit_stack_get_viewer (_tmp1_);
	_tmp3_ = _tmp2_;
	enotes_viewer_reload_page (_tmp3_);
	_g_object_unref0 (_tmp1_);
}

static void
____lambda59__gtk_combo_box_changed (GtkComboBox* _sender,
                                     gpointer self)
{
	___lambda59_ ((ENotesNotebookDialog*) self);
}

ENotesNotebookDialog*
enotes_notebook_dialog_construct (GType object_type,
                                  ENotesNotebook* notebook)
{
	ENotesNotebookDialog * self = NULL;
	ENotesNotebook* _tmp0_;
	ENotesApplication* _tmp1_;
	ENotesWindow* _tmp2_;
	ENotesWindow* _tmp3_;
	self = (ENotesNotebookDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (notebook);
	_g_object_unref0 (self->priv->notebook);
	self->priv->notebook = _tmp0_;
	_tmp1_ = enotes_app;
	_tmp2_ = enotes_application_get_app_window (_tmp1_);
	_tmp3_ = _tmp2_;
	gtk_window_set_transient_for ((GtkWindow*) self, (GtkWindow*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	enotes_notebook_dialog_build_ui (self);
	enotes_notebook_dialog_connect_signals (self);
	if (notebook != NULL) {
		GtkComboBox* _tmp4_;
		enotes_notebook_dialog_load_data (self);
		_tmp4_ = self->priv->style_box;
		g_signal_connect_object (_tmp4_, "changed", (GCallback) ____lambda59__gtk_combo_box_changed, self, 0);
	}
	gtk_widget_show_all ((GtkWidget*) self);
	return self;
}

ENotesNotebookDialog*
enotes_notebook_dialog_new (ENotesNotebook* notebook)
{
	return enotes_notebook_dialog_construct (ENOTES_TYPE_NOTEBOOK_DIALOG, notebook);
}

ENotesNotebookDialog*
enotes_notebook_dialog_construct_new_subnotebook (GType object_type,
                                                  ENotesNotebook* parent)
{
	ENotesNotebookDialog * self = NULL;
	ENotesNotebook* _tmp0_;
	GtkComboBox* _tmp1_;
	ENotesNotebook* _tmp2_;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (ENotesNotebookDialog*) enotes_notebook_dialog_construct (object_type, NULL);
	_tmp0_ = _g_object_ref0 (parent);
	_g_object_unref0 (self->priv->parent_nb);
	self->priv->parent_nb = _tmp0_;
	_tmp1_ = self->priv->style_box;
	_tmp2_ = self->priv->parent_nb;
	gtk_combo_box_set_active (_tmp1_, enotes_notebook_dialog_get_notebook_style (self, _tmp2_));
	return self;
}

ENotesNotebookDialog*
enotes_notebook_dialog_new_new_subnotebook (ENotesNotebook* parent)
{
	return enotes_notebook_dialog_construct_new_subnotebook (ENOTES_TYPE_NOTEBOOK_DIALOG, parent);
}

void
enotes_notebook_dialog_build_ui (ENotesNotebookDialog* self)
{
	GtkLabel* name_label = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* color_label = NULL;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkEntry* _tmp4_;
	ENotesNotebook* _tmp5_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp20_;
	GtkLabel* _tmp21_;
	GtkEntry* _tmp22_;
	GtkLabel* _tmp23_;
	GtkColorButton* _tmp24_;
	GtkStack* _tmp25_;
	GtkStack* _tmp26_;
	GtkStack* _tmp27_;
	GtkGrid* _tmp28_;
	GtkGrid* _tmp29_;
	GtkStack* _tmp30_;
	GtkStack* _tmp31_;
	GtkStackSwitcher* switcher = NULL;
	GtkStackSwitcher* _tmp32_;
	GtkStack* _tmp33_;
	GtkBox* box = NULL;
	GtkBox* _tmp34_;
	GtkStack* _tmp35_;
	GtkBox* _tmp36_;
	g_return_if_fail (self != NULL);
	gtk_container_set_border_width ((GtkContainer*) self, (guint) 12);
	gtk_window_set_keep_above ((GtkWindow*) self, TRUE);
	gtk_widget_set_size_request ((GtkWidget*) self, 360, 280);
	gtk_window_set_resizable ((GtkWindow*) self, FALSE);
	gtk_window_set_deletable ((GtkWindow*) self, FALSE);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	_tmp0_ = (GtkLabel*) gtk_label_new (_ ("Name:"));
	g_object_ref_sink (_tmp0_);
	name_label = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (_ ("Color:"));
	g_object_ref_sink (_tmp1_);
	color_label = _tmp1_;
	_tmp2_ = name_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp2_, GTK_ALIGN_END);
	_tmp3_ = color_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_END);
	enotes_notebook_dialog_make_store (self);
	_tmp4_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->name_entry);
	self->priv->name_entry = _tmp4_;
	gtk_dialog_add_button ((GtkDialog*) self, _ ("Cancel"), 2);
	_tmp5_ = self->priv->notebook;
	if (_tmp5_ != NULL) {
		GdkRGBA color = {0};
		ENotesNotebook* _tmp6_;
		GdkRGBA _tmp7_;
		ENotesNotebook* _tmp8_;
		GdkRGBA _tmp9_;
		ENotesNotebook* _tmp10_;
		GdkRGBA _tmp11_;
		GdkRGBA _tmp12_;
		GtkColorButton* _tmp13_;
		GtkWidget* _tmp14_;
		GtkButton* _tmp15_;
		memset (&color, 0, sizeof (GdkRGBA));
		_tmp6_ = self->priv->notebook;
		_tmp7_ = _tmp6_->rgb;
		color.red = _tmp7_.red;
		_tmp8_ = self->priv->notebook;
		_tmp9_ = _tmp8_->rgb;
		color.green = _tmp9_.green;
		_tmp10_ = self->priv->notebook;
		_tmp11_ = _tmp10_->rgb;
		color.blue = _tmp11_.blue;
		color.alpha = (gdouble) 1;
		_tmp12_ = color;
		_tmp13_ = (GtkColorButton*) gtk_color_button_new_with_rgba (&_tmp12_);
		g_object_ref_sink (_tmp13_);
		_g_object_unref0 (self->priv->color_button);
		self->priv->color_button = _tmp13_;
		_tmp14_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("Edit"), 1);
		_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_button_get_type (), GtkButton));
		_g_object_unref0 (self->priv->create);
		self->priv->create = _tmp15_;
	} else {
		GtkColorButton* _tmp16_;
		GtkWidget* _tmp17_;
		GtkButton* _tmp18_;
		GtkButton* _tmp19_;
		_tmp16_ = (GtkColorButton*) gtk_color_button_new ();
		g_object_ref_sink (_tmp16_);
		_g_object_unref0 (self->priv->color_button);
		self->priv->color_button = _tmp16_;
		_tmp17_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("Create"), 1);
		_tmp18_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, gtk_button_get_type (), GtkButton));
		_g_object_unref0 (self->priv->create);
		self->priv->create = _tmp18_;
		_tmp19_ = self->priv->create;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp19_, FALSE);
	}
	_tmp20_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp20_);
	grid = _tmp20_;
	_tmp21_ = name_label;
	gtk_grid_attach (grid, (GtkWidget*) _tmp21_, 0, 1, 1, 1);
	_tmp22_ = self->priv->name_entry;
	gtk_grid_attach (grid, (GtkWidget*) _tmp22_, 1, 1, 1, 1);
	_tmp23_ = color_label;
	gtk_grid_attach (grid, (GtkWidget*) _tmp23_, 0, 2, 1, 1);
	_tmp24_ = self->priv->color_button;
	gtk_grid_attach (grid, (GtkWidget*) _tmp24_, 1, 2, 1, 1);
	gtk_grid_set_column_homogeneous (grid, FALSE);
	gtk_grid_set_row_homogeneous (grid, TRUE);
	gtk_widget_set_margin_bottom ((GtkWidget*) grid, 12);
	gtk_grid_set_column_spacing (grid, 12);
	gtk_grid_set_row_spacing (grid, 6);
	gtk_widget_set_valign ((GtkWidget*) grid, GTK_ALIGN_START);
	_tmp25_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp25_);
	_g_object_unref0 (self->priv->stack);
	self->priv->stack = _tmp25_;
	_tmp26_ = self->priv->stack;
	gtk_stack_add_titled (_tmp26_, (GtkWidget*) grid, "properties", _ ("Properties"));
	_tmp27_ = self->priv->stack;
	_tmp28_ = enotes_notebook_dialog_viewer_grid (self);
	_tmp29_ = _tmp28_;
	gtk_stack_add_titled (_tmp27_, (GtkWidget*) _tmp29_, "style", _ ("Style"));
	_g_object_unref0 (_tmp29_);
	_tmp30_ = self->priv->stack;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp30_, 12);
	_tmp31_ = self->priv->stack;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp31_, 12);
	_tmp32_ = (GtkStackSwitcher*) gtk_stack_switcher_new ();
	g_object_ref_sink (_tmp32_);
	switcher = _tmp32_;
	_tmp33_ = self->priv->stack;
	gtk_stack_switcher_set_stack (switcher, _tmp33_);
	gtk_widget_set_halign ((GtkWidget*) switcher, GTK_ALIGN_CENTER);
	_tmp34_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp34_);
	box = _tmp34_;
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) switcher);
	_tmp35_ = self->priv->stack;
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) _tmp35_);
	_tmp36_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	gtk_container_add ((GtkContainer*) _tmp36_, (GtkWidget*) box);
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (box);
	_g_object_unref0 (switcher);
	_g_object_unref0 (grid);
	_g_object_unref0 (color_label);
	_g_object_unref0 (name_label);
}

static GtkGrid*
enotes_notebook_dialog_viewer_grid (ENotesNotebookDialog* self)
{
	GtkLabel* title = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkTextView* _tmp4_;
	GtkTextView* _tmp5_;
	GtkTextView* _tmp6_;
	GtkTextView* _tmp7_;
	GtkScrolledWindow* scrolled = NULL;
	GtkScrolledWindow* _tmp8_;
	GtkTextView* _tmp9_;
	GtkLabel* styles_label = NULL;
	GtkLabel* _tmp10_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp11_;
	GtkComboBox* _tmp12_;
	GtkGrid* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup_printf ("<b>%s</b>", _ ("Style modifications"));
	_tmp1_ = _tmp0_;
	_tmp2_ = (GtkLabel*) gtk_label_new (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	title = _tmp3_;
	gtk_label_set_use_markup (title, TRUE);
	gtk_widget_set_halign ((GtkWidget*) title, GTK_ALIGN_START);
	_tmp4_ = (GtkTextView*) gtk_text_view_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->style_changes);
	self->priv->style_changes = _tmp4_;
	_tmp5_ = self->priv->style_changes;
	gtk_text_view_set_wrap_mode (_tmp5_, GTK_WRAP_WORD);
	_tmp6_ = self->priv->style_changes;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp6_, TRUE);
	_tmp7_ = self->priv->style_changes;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp7_, TRUE);
	_tmp8_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp8_);
	scrolled = _tmp8_;
	g_object_set ((GtkWidget*) scrolled, "height-request", 90, NULL);
	_tmp9_ = self->priv->style_changes;
	gtk_container_add ((GtkContainer*) scrolled, (GtkWidget*) _tmp9_);
	_tmp10_ = (GtkLabel*) gtk_label_new (_ ("Stylesheet:"));
	g_object_ref_sink (_tmp10_);
	styles_label = _tmp10_;
	gtk_widget_set_halign ((GtkWidget*) styles_label, GTK_ALIGN_END);
	enotes_notebook_dialog_make_store (self);
	_tmp11_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp11_);
	grid = _tmp11_;
	gtk_grid_set_column_homogeneous (grid, FALSE);
	gtk_grid_set_row_homogeneous (grid, FALSE);
	gtk_grid_set_row_spacing (grid, 8);
	gtk_grid_set_column_spacing (grid, 8);
	gtk_grid_attach (grid, (GtkWidget*) styles_label, 0, 2, 1, 1);
	_tmp12_ = self->priv->style_box;
	gtk_grid_attach (grid, (GtkWidget*) _tmp12_, 1, 2, 1, 1);
	gtk_grid_attach (grid, (GtkWidget*) title, 0, 0, 2, 1);
	gtk_grid_attach (grid, (GtkWidget*) scrolled, 0, 1, 2, 1);
	result = grid;
	_g_object_unref0 (styles_label);
	_g_object_unref0 (scrolled);
	_g_object_unref0 (title);
	return result;
}

static void
enotes_notebook_dialog_make_store (ENotesNotebookDialog* self)
{
	GtkListStore* list_store = NULL;
	GtkListStore* _tmp0_;
	GtkTreeIter iter = {0};
	gint value = 0;
	gchar** _tmp1_;
	gint _tmp1__length1;
	GtkListStore* _tmp8_;
	GtkComboBox* _tmp9_;
	GtkCellRendererText* renderer = NULL;
	GtkCellRendererText* _tmp10_;
	GtkComboBox* _tmp11_;
	GtkComboBox* _tmp12_;
	GtkComboBox* _tmp13_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT, -1);
	list_store = _tmp0_;
	value = 0;
	_tmp1_ = enotes_style_loader_STYLES;
	_tmp1__length1 = enotes_style_loader_STYLES_length1;
	{
		gchar** style_collection = NULL;
		gint style_collection_length1 = 0;
		gint _style_collection_size_ = 0;
		gint style_it = 0;
		style_collection = _tmp1_;
		style_collection_length1 = _tmp1__length1;
		for (style_it = 0; style_it < style_collection_length1; style_it = style_it + 1) {
			gchar* _tmp2_;
			gchar* style = NULL;
			_tmp2_ = g_strdup (style_collection[style_it]);
			style = _tmp2_;
			{
				GtkListStore* _tmp3_;
				GtkTreeIter _tmp4_ = {0};
				GtkListStore* _tmp5_;
				GtkTreeIter _tmp6_;
				const gchar* _tmp7_;
				_tmp3_ = list_store;
				gtk_list_store_append (_tmp3_, &_tmp4_);
				iter = _tmp4_;
				_tmp5_ = list_store;
				_tmp6_ = iter;
				_tmp7_ = style;
				gtk_list_store_set (_tmp5_, &_tmp6_, 0, _tmp7_, 1, value, -1);
				_g_free0 (style);
			}
		}
	}
	_tmp8_ = list_store;
	_tmp9_ = (GtkComboBox*) gtk_combo_box_new_with_model ((GtkTreeModel*) _tmp8_);
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->style_box);
	self->priv->style_box = _tmp9_;
	_tmp10_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp10_);
	renderer = _tmp10_;
	_tmp11_ = self->priv->style_box;
	gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp11_, (GtkCellRenderer*) renderer, TRUE);
	_tmp12_ = self->priv->style_box;
	gtk_cell_layout_add_attribute ((GtkCellLayout*) _tmp12_, (GtkCellRenderer*) renderer, "text", 0);
	_tmp13_ = self->priv->style_box;
	gtk_combo_box_set_active (_tmp13_, 0);
	_g_object_unref0 (renderer);
	_g_object_unref0 (list_store);
}

static gint
enotes_notebook_dialog_get_notebook_style (ENotesNotebookDialog* self,
                                           ENotesNotebook* notebook)
{
	gint active = 0;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (notebook != NULL, -1);
	active = 0;
	_tmp0_ = enotes_style_loader_STYLES;
	_tmp0__length1 = enotes_style_loader_STYLES_length1;
	{
		gchar** style_collection = NULL;
		gint style_collection_length1 = 0;
		gint _style_collection_size_ = 0;
		gint style_it = 0;
		style_collection = _tmp0_;
		style_collection_length1 = _tmp0__length1;
		for (style_it = 0; style_it < style_collection_length1; style_it = style_it + 1) {
			gchar* _tmp1_;
			gchar* style = NULL;
			_tmp1_ = g_strdup (style_collection[style_it]);
			style = _tmp1_;
			{
				const gchar* _tmp2_;
				const gchar* _tmp3_;
				gint _tmp4_;
				_tmp2_ = notebook->stylesheet;
				_tmp3_ = style;
				if (g_strcmp0 (_tmp2_, _tmp3_) == 0) {
					result = active;
					_g_free0 (style);
					return result;
				}
				_tmp4_ = active;
				active = _tmp4_ + 1;
				_g_free0 (style);
			}
		}
	}
	result = 0;
	return result;
}

static void
enotes_notebook_dialog_load_data (ENotesNotebookDialog* self)
{
	GtkEntry* _tmp0_;
	ENotesNotebook* _tmp1_;
	const gchar* _tmp2_;
	GtkComboBox* _tmp3_;
	ENotesNotebook* _tmp4_;
	GtkTextView* _tmp5_;
	GtkTextBuffer* _tmp6_;
	GtkTextBuffer* _tmp7_;
	ENotesNotebook* _tmp8_;
	const gchar* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->name_entry;
	_tmp1_ = self->priv->notebook;
	_tmp2_ = _tmp1_->name;
	gtk_entry_set_text (_tmp0_, _tmp2_);
	_tmp3_ = self->priv->style_box;
	_tmp4_ = self->priv->notebook;
	gtk_combo_box_set_active (_tmp3_, enotes_notebook_dialog_get_notebook_style (self, _tmp4_));
	_tmp5_ = self->priv->style_changes;
	_tmp6_ = gtk_text_view_get_buffer (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->priv->notebook;
	_tmp9_ = _tmp8_->css;
	g_object_set (_tmp7_, "text", _tmp9_, NULL);
}

static void
__lambda57_ (ENotesNotebookDialog* self,
             gint ID)
{
	switch (ID) {
		case 1:
		{
			gdouble r = 0.0;
			GtkColorButton* _tmp0_;
			GdkRGBA _tmp1_ = {0};
			GdkRGBA _tmp2_;
			gdouble g = 0.0;
			GtkColorButton* _tmp3_;
			GdkRGBA _tmp4_ = {0};
			GdkRGBA _tmp5_;
			gdouble b = 0.0;
			GtkColorButton* _tmp6_;
			GdkRGBA _tmp7_ = {0};
			GdkRGBA _tmp8_;
			ENotesNotebook* _tmp9_;
			ENotesViewEditStack* _tmp86_;
			ENotesViewEditStack* _tmp87_;
			ENotesViewer* _tmp88_;
			ENotesViewer* _tmp89_;
			_tmp0_ = self->priv->color_button;
			gtk_color_chooser_get_rgba ((GtkColorChooser*) _tmp0_, &_tmp1_);
			_tmp2_ = _tmp1_;
			r = _tmp2_.red;
			_tmp3_ = self->priv->color_button;
			gtk_color_chooser_get_rgba ((GtkColorChooser*) _tmp3_, &_tmp4_);
			_tmp5_ = _tmp4_;
			g = _tmp5_.green;
			_tmp6_ = self->priv->color_button;
			gtk_color_chooser_get_rgba ((GtkColorChooser*) _tmp6_, &_tmp7_);
			_tmp8_ = _tmp7_;
			b = _tmp8_.blue;
			_tmp9_ = self->priv->notebook;
			if (_tmp9_ == NULL) {
				ENotesNotebook* _tmp10_;
				_tmp10_ = self->priv->parent_nb;
				if (_tmp10_ == NULL) {
					ENotesNotebookTable* _tmp11_;
					ENotesNotebookTable* _tmp12_;
					GtkEntry* _tmp13_;
					const gchar* _tmp14_;
					const gchar* _tmp15_;
					GdkRGBA _tmp16_ = {0};
					GtkTextView* _tmp17_;
					GtkTextBuffer* _tmp18_;
					GtkTextBuffer* _tmp19_;
					gchar* _tmp20_;
					gchar* _tmp21_;
					gchar* _tmp22_;
					gchar** _tmp23_;
					gint _tmp23__length1;
					GtkComboBox* _tmp24_;
					gint _tmp25_;
					gint _tmp26_;
					const gchar* _tmp27_;
					_tmp11_ = enotes_notebook_table_get_instance ();
					_tmp12_ = _tmp11_;
					_tmp13_ = self->priv->name_entry;
					_tmp14_ = gtk_entry_get_text (_tmp13_);
					_tmp15_ = _tmp14_;
					_tmp16_.red = r;
					_tmp16_.green = g;
					_tmp16_.blue = b;
					_tmp17_ = self->priv->style_changes;
					_tmp18_ = gtk_text_view_get_buffer (_tmp17_);
					_tmp19_ = _tmp18_;
					g_object_get (_tmp19_, "text", &_tmp20_, NULL);
					_tmp21_ = _tmp20_;
					_tmp22_ = _tmp21_;
					_tmp23_ = enotes_style_loader_STYLES;
					_tmp23__length1 = enotes_style_loader_STYLES_length1;
					_tmp24_ = self->priv->style_box;
					_tmp25_ = gtk_combo_box_get_active (_tmp24_);
					_tmp26_ = _tmp25_;
					_tmp27_ = _tmp23_[_tmp26_];
					enotes_notebook_table_new_notebook (_tmp12_, (gint64) 0, _tmp15_, &_tmp16_, _tmp22_, _tmp27_);
					_g_free0 (_tmp22_);
					_database_table_unref0 (_tmp12_);
				} else {
					ENotesNotebookTable* _tmp28_;
					ENotesNotebookTable* _tmp29_;
					ENotesNotebook* _tmp30_;
					GtkEntry* _tmp31_;
					const gchar* _tmp32_;
					const gchar* _tmp33_;
					GdkRGBA _tmp34_ = {0};
					GtkTextView* _tmp35_;
					GtkTextBuffer* _tmp36_;
					GtkTextBuffer* _tmp37_;
					gchar* _tmp38_;
					gchar* _tmp39_;
					gchar* _tmp40_;
					gchar** _tmp41_;
					gint _tmp41__length1;
					GtkComboBox* _tmp42_;
					gint _tmp43_;
					gint _tmp44_;
					const gchar* _tmp45_;
					_tmp28_ = enotes_notebook_table_get_instance ();
					_tmp29_ = _tmp28_;
					_tmp30_ = self->priv->parent_nb;
					_tmp31_ = self->priv->name_entry;
					_tmp32_ = gtk_entry_get_text (_tmp31_);
					_tmp33_ = _tmp32_;
					_tmp34_.red = r;
					_tmp34_.green = g;
					_tmp34_.blue = b;
					_tmp35_ = self->priv->style_changes;
					_tmp36_ = gtk_text_view_get_buffer (_tmp35_);
					_tmp37_ = _tmp36_;
					g_object_get (_tmp37_, "text", &_tmp38_, NULL);
					_tmp39_ = _tmp38_;
					_tmp40_ = _tmp39_;
					_tmp41_ = enotes_style_loader_STYLES;
					_tmp41__length1 = enotes_style_loader_STYLES_length1;
					_tmp42_ = self->priv->style_box;
					_tmp43_ = gtk_combo_box_get_active (_tmp42_);
					_tmp44_ = _tmp43_;
					_tmp45_ = _tmp41_[_tmp44_];
					enotes_notebook_table_new_notebook (_tmp29_, _tmp30_->id, _tmp33_, &_tmp34_, _tmp40_, _tmp45_);
					_g_free0 (_tmp40_);
					_database_table_unref0 (_tmp29_);
				}
			} else {
				gboolean _tmp46_ = FALSE;
				GtkTextView* _tmp47_;
				GtkTextBuffer* _tmp48_;
				GtkTextBuffer* _tmp49_;
				gchar* _tmp50_;
				gchar* _tmp51_;
				gchar* _tmp52_;
				ENotesNotebook* _tmp53_;
				const gchar* _tmp54_;
				gboolean _tmp55_;
				ENotesNotebookTable* _tmp66_;
				ENotesNotebookTable* _tmp67_;
				ENotesNotebook* _tmp68_;
				GtkEntry* _tmp69_;
				const gchar* _tmp70_;
				const gchar* _tmp71_;
				GdkRGBA _tmp72_ = {0};
				GtkTextView* _tmp73_;
				GtkTextBuffer* _tmp74_;
				GtkTextBuffer* _tmp75_;
				gchar* _tmp76_;
				gchar* _tmp77_;
				gchar* _tmp78_;
				gchar** _tmp79_;
				gint _tmp79__length1;
				GtkComboBox* _tmp80_;
				gint _tmp81_;
				gint _tmp82_;
				const gchar* _tmp83_;
				ENotesApplication* _tmp84_;
				ENotesApplicationState* _tmp85_;
				_tmp47_ = self->priv->style_changes;
				_tmp48_ = gtk_text_view_get_buffer (_tmp47_);
				_tmp49_ = _tmp48_;
				g_object_get (_tmp49_, "text", &_tmp50_, NULL);
				_tmp51_ = _tmp50_;
				_tmp52_ = _tmp51_;
				_tmp53_ = self->priv->notebook;
				_tmp54_ = _tmp53_->css;
				_tmp55_ = g_strcmp0 (_tmp52_, _tmp54_) != 0;
				_g_free0 (_tmp52_);
				if (_tmp55_) {
					_tmp46_ = TRUE;
				} else {
					gchar** _tmp56_;
					gint _tmp56__length1;
					GtkComboBox* _tmp57_;
					gint _tmp58_;
					gint _tmp59_;
					const gchar* _tmp60_;
					ENotesNotebook* _tmp61_;
					const gchar* _tmp62_;
					_tmp56_ = enotes_style_loader_STYLES;
					_tmp56__length1 = enotes_style_loader_STYLES_length1;
					_tmp57_ = self->priv->style_box;
					_tmp58_ = gtk_combo_box_get_active (_tmp57_);
					_tmp59_ = _tmp58_;
					_tmp60_ = _tmp56_[_tmp59_];
					_tmp61_ = self->priv->notebook;
					_tmp62_ = _tmp61_->stylesheet;
					_tmp46_ = g_strcmp0 (_tmp60_, _tmp62_) != 0;
				}
				if (_tmp46_) {
					ENotesPageTable* _tmp63_;
					ENotesPageTable* _tmp64_;
					ENotesNotebook* _tmp65_;
					_tmp63_ = enotes_page_table_get_instance ();
					_tmp64_ = _tmp63_;
					_tmp65_ = self->priv->notebook;
					enotes_page_table_clear_cache_on (_tmp64_, _tmp65_->id);
					_database_table_unref0 (_tmp64_);
				}
				_tmp66_ = enotes_notebook_table_get_instance ();
				_tmp67_ = _tmp66_;
				_tmp68_ = self->priv->notebook;
				_tmp69_ = self->priv->name_entry;
				_tmp70_ = gtk_entry_get_text (_tmp69_);
				_tmp71_ = _tmp70_;
				_tmp72_.red = r;
				_tmp72_.green = g;
				_tmp72_.blue = b;
				_tmp73_ = self->priv->style_changes;
				_tmp74_ = gtk_text_view_get_buffer (_tmp73_);
				_tmp75_ = _tmp74_;
				g_object_get (_tmp75_, "text", &_tmp76_, NULL);
				_tmp77_ = _tmp76_;
				_tmp78_ = _tmp77_;
				_tmp79_ = enotes_style_loader_STYLES;
				_tmp79__length1 = enotes_style_loader_STYLES_length1;
				_tmp80_ = self->priv->style_box;
				_tmp81_ = gtk_combo_box_get_active (_tmp80_);
				_tmp82_ = _tmp81_;
				_tmp83_ = _tmp79_[_tmp82_];
				enotes_notebook_table_save_notebook (_tmp67_, _tmp68_->id, _tmp71_, &_tmp72_, _tmp78_, _tmp83_);
				_g_free0 (_tmp78_);
				_database_table_unref0 (_tmp67_);
				_tmp84_ = enotes_app;
				_tmp85_ = _tmp84_->state;
				g_signal_emit_by_name (_tmp85_, "opened-notebook-updated");
			}
			_tmp86_ = enotes_view_edit_stack_get_instance ();
			_tmp87_ = _tmp86_;
			_tmp88_ = enotes_view_edit_stack_get_viewer (_tmp87_);
			_tmp89_ = _tmp88_;
			enotes_viewer_reload_page (_tmp89_);
			_g_object_unref0 (_tmp87_);
			g_signal_emit_by_name ((GtkDialog*) self, "close");
			break;
		}
		case 2:
		{
			g_signal_emit_by_name ((GtkDialog*) self, "close");
			break;
		}
		default:
		break;
	}
}

static void
___lambda57__gtk_dialog_response (GtkDialog* _sender,
                                  gint response_id,
                                  gpointer self)
{
	__lambda57_ ((ENotesNotebookDialog*) self, response_id);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static void
__lambda58_ (ENotesNotebookDialog* self)
{
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gboolean _tmp5_;
	_tmp0_ = self->priv->name_entry;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_strip (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strcmp0 (_tmp4_, "") == 0;
	_g_free0 (_tmp4_);
	if (_tmp5_) {
		GtkButton* _tmp6_;
		_tmp6_ = self->priv->create;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp6_, FALSE);
	} else {
		GtkButton* _tmp7_;
		_tmp7_ = self->priv->create;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp7_, TRUE);
	}
}

static void
___lambda58__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda58_ ((ENotesNotebookDialog*) self);
}

static void
enotes_notebook_dialog_connect_signals (ENotesNotebookDialog* self)
{
	GtkEntry* _tmp0_;
	g_return_if_fail (self != NULL);
	g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) ___lambda57__gtk_dialog_response, self, 0);
	_tmp0_ = self->priv->name_entry;
	g_signal_connect_object ((GObject*) _tmp0_, "notify::text", (GCallback) ___lambda58__g_object_notify, self, 0);
}

static void
enotes_notebook_dialog_class_init (ENotesNotebookDialogClass * klass,
                                   gpointer klass_data)
{
	enotes_notebook_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ENotesNotebookDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = enotes_notebook_dialog_finalize;
}

static void
enotes_notebook_dialog_instance_init (ENotesNotebookDialog * self,
                                      gpointer klass)
{
	self->priv = enotes_notebook_dialog_get_instance_private (self);
}

static void
enotes_notebook_dialog_finalize (GObject * obj)
{
	ENotesNotebookDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ENOTES_TYPE_NOTEBOOK_DIALOG, ENotesNotebookDialog);
	_g_object_unref0 (self->priv->stack);
	_g_object_unref0 (self->priv->name_entry);
	_g_object_unref0 (self->priv->color_button);
	_g_object_unref0 (self->priv->style_box);
	_g_object_unref0 (self->priv->style_changes);
	_g_object_unref0 (self->priv->create);
	_g_object_unref0 (self->priv->notebook);
	_g_object_unref0 (self->priv->parent_nb);
	G_OBJECT_CLASS (enotes_notebook_dialog_parent_class)->finalize (obj);
}

static GType
enotes_notebook_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ENotesNotebookDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) enotes_notebook_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ENotesNotebookDialog), 0, (GInstanceInitFunc) enotes_notebook_dialog_instance_init, NULL };
	GType enotes_notebook_dialog_type_id;
	enotes_notebook_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "ENotesNotebookDialog", &g_define_type_info, 0);
	ENotesNotebookDialog_private_offset = g_type_add_instance_private (enotes_notebook_dialog_type_id, sizeof (ENotesNotebookDialogPrivate));
	return enotes_notebook_dialog_type_id;
}

GType
enotes_notebook_dialog_get_type (void)
{
	static volatile gsize enotes_notebook_dialog_type_id__once = 0;
	if (g_once_init_enter (&enotes_notebook_dialog_type_id__once)) {
		GType enotes_notebook_dialog_type_id;
		enotes_notebook_dialog_type_id = enotes_notebook_dialog_get_type_once ();
		g_once_init_leave (&enotes_notebook_dialog_type_id__once, enotes_notebook_dialog_type_id);
	}
	return enotes_notebook_dialog_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;
}

