/* templates_dialogs.c generated by valac 0.21.2.9-2b15d, the Vala compiler
 * generated from templates_dialogs.vala, do not modify */

/*
 * This file is part of LaTeXila.
 *
 * Copyright © 2012 Sébastien Wilmet
 *
 * LaTeXila 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 3 of the License, or
 * (at your option) any later version.
 *
 * LaTeXila 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 LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gtksourceview/gtksource.h>
#include <gobject/gvaluecollector.h>


#define TYPE_OPEN_TEMPLATE_DIALOG (open_template_dialog_get_type ())
#define OPEN_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_OPEN_TEMPLATE_DIALOG, OpenTemplateDialog))
#define OPEN_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_OPEN_TEMPLATE_DIALOG, OpenTemplateDialogClass))
#define IS_OPEN_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_OPEN_TEMPLATE_DIALOG))
#define IS_OPEN_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OPEN_TEMPLATE_DIALOG))
#define OPEN_TEMPLATE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OPEN_TEMPLATE_DIALOG, OpenTemplateDialogClass))

typedef struct _OpenTemplateDialog OpenTemplateDialog;
typedef struct _OpenTemplateDialogClass OpenTemplateDialogClass;
typedef struct _OpenTemplateDialogPrivate OpenTemplateDialogPrivate;

#define TYPE_MAIN_WINDOW (main_window_get_type ())
#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))

typedef struct _MainWindow MainWindow;
typedef struct _MainWindowClass MainWindowClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_TEMPLATES (templates_get_type ())
#define TEMPLATES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEMPLATES, Templates))
#define TEMPLATES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TEMPLATES, TemplatesClass))
#define IS_TEMPLATES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEMPLATES))
#define IS_TEMPLATES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TEMPLATES))
#define TEMPLATES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TEMPLATES, TemplatesClass))

typedef struct _Templates Templates;
typedef struct _TemplatesClass TemplatesClass;
typedef struct _Block33Data Block33Data;
#define _open_template_dialog_unref0(var) ((var == NULL) ? NULL : (var = (open_template_dialog_unref (var), NULL)))
#define __g_list_free__gtk_tree_path_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__gtk_tree_path_free0_ (var), NULL)))
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_DOCUMENT_TAB (document_tab_get_type ())
#define DOCUMENT_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT_TAB, DocumentTab))
#define DOCUMENT_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT_TAB, DocumentTabClass))
#define IS_DOCUMENT_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT_TAB))
#define IS_DOCUMENT_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT_TAB))
#define DOCUMENT_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT_TAB, DocumentTabClass))

typedef struct _DocumentTab DocumentTab;
typedef struct _DocumentTabClass DocumentTabClass;

#define TYPE_DOCUMENT (document_get_type ())
#define DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT, Document))
#define DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT, DocumentClass))
#define IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT))
#define IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT))
#define DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT, DocumentClass))

typedef struct _Document Document;
typedef struct _DocumentClass DocumentClass;
typedef struct _ParamSpecOpenTemplateDialog ParamSpecOpenTemplateDialog;

#define TYPE_CREATE_TEMPLATE_DIALOG (create_template_dialog_get_type ())
#define CREATE_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CREATE_TEMPLATE_DIALOG, CreateTemplateDialog))
#define CREATE_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CREATE_TEMPLATE_DIALOG, CreateTemplateDialogClass))
#define IS_CREATE_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CREATE_TEMPLATE_DIALOG))
#define IS_CREATE_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CREATE_TEMPLATE_DIALOG))
#define CREATE_TEMPLATE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CREATE_TEMPLATE_DIALOG, CreateTemplateDialogClass))

typedef struct _CreateTemplateDialog CreateTemplateDialog;
typedef struct _CreateTemplateDialogClass CreateTemplateDialogClass;
typedef struct _CreateTemplateDialogPrivate CreateTemplateDialogPrivate;

#define TYPE_DELETE_TEMPLATE_DIALOG (delete_template_dialog_get_type ())
#define DELETE_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DELETE_TEMPLATE_DIALOG, DeleteTemplateDialog))
#define DELETE_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DELETE_TEMPLATE_DIALOG, DeleteTemplateDialogClass))
#define IS_DELETE_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DELETE_TEMPLATE_DIALOG))
#define IS_DELETE_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DELETE_TEMPLATE_DIALOG))
#define DELETE_TEMPLATE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DELETE_TEMPLATE_DIALOG, DeleteTemplateDialogClass))

typedef struct _DeleteTemplateDialog DeleteTemplateDialog;
typedef struct _DeleteTemplateDialogClass DeleteTemplateDialogClass;
typedef struct _DeleteTemplateDialogPrivate DeleteTemplateDialogPrivate;

struct _OpenTemplateDialog {
	GTypeInstance parent_instance;
	volatile int ref_count;
	OpenTemplateDialogPrivate * priv;
};

struct _OpenTemplateDialogClass {
	GTypeClass parent_class;
	void (*finalize) (OpenTemplateDialog *self);
};

struct _OpenTemplateDialogPrivate {
	MainWindow* _main_window;
	GtkDialog* _dialog;
	GtkTreeView* _default_templates;
	GtkTreeView* _personal_templates;
};

struct _Block33Data {
	int _ref_count_;
	OpenTemplateDialog * self;
	GtkTreeSelection* default_select;
	GtkTreeSelection* personal_select;
};

struct _ParamSpecOpenTemplateDialog {
	GParamSpec parent_instance;
};

struct _CreateTemplateDialog {
	GtkDialog parent_instance;
	CreateTemplateDialogPrivate * priv;
};

struct _CreateTemplateDialogClass {
	GtkDialogClass parent_class;
};

struct _DeleteTemplateDialog {
	GtkDialog parent_instance;
	DeleteTemplateDialogPrivate * priv;
};

struct _DeleteTemplateDialogClass {
	GtkDialogClass parent_class;
};


static gpointer open_template_dialog_parent_class = NULL;
static gpointer create_template_dialog_parent_class = NULL;
static gpointer delete_template_dialog_parent_class = NULL;

gpointer open_template_dialog_ref (gpointer instance);
void open_template_dialog_unref (gpointer instance);
GParamSpec* param_spec_open_template_dialog (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_open_template_dialog (GValue* value, gpointer v_object);
void value_take_open_template_dialog (GValue* value, gpointer v_object);
gpointer value_get_open_template_dialog (const GValue* value);
GType open_template_dialog_get_type (void) G_GNUC_CONST;
GType main_window_get_type (void) G_GNUC_CONST;
#define OPEN_TEMPLATE_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_OPEN_TEMPLATE_DIALOG, OpenTemplateDialogPrivate))
enum  {
	OPEN_TEMPLATE_DIALOG_DUMMY_PROPERTY
};
OpenTemplateDialog* open_template_dialog_new (MainWindow* main_window);
OpenTemplateDialog* open_template_dialog_construct (GType object_type, MainWindow* main_window);
GType templates_get_type (void) G_GNUC_CONST;
Templates* templates_get_default (void);
GtkTreeView* templates_get_default_templates_list (Templates* self);
GtkScrolledWindow* utils_add_scrollbar (GtkWidget* child);
GtkGrid* utils_get_dialog_component (const gchar* title, GtkWidget* widget);
GtkTreeView* templates_get_personal_templates_list (Templates* self);
static void open_template_dialog_connect_to_signals (OpenTemplateDialog* self);
static void open_template_dialog_run_me (OpenTemplateDialog* self);
static Block33Data* block33_data_ref (Block33Data* _data33_);
static void block33_data_unref (void * _userdata_);
static void __lambda102_ (Block33Data* _data33_);
static void open_template_dialog_on_list_selection_changed (OpenTemplateDialog* self, GtkTreeSelection* select, GtkTreeSelection* other_select);
static void ___lambda102__gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self);
static void __lambda103_ (Block33Data* _data33_);
static void ___lambda103__gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self);
static void __lambda104_ (OpenTemplateDialog* self, GtkTreePath* path);
static void open_template_dialog_open_default_template (OpenTemplateDialog* self, GtkTreePath* path);
static void ___lambda104__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self);
static void __lambda105_ (OpenTemplateDialog* self, GtkTreePath* path);
static void open_template_dialog_open_personal_template (OpenTemplateDialog* self, GtkTreePath* path);
static void ___lambda105__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self);
static void _gtk_tree_path_free0_ (gpointer var);
static void _g_list_free__gtk_tree_path_free0_ (GList* self);
static void open_template_dialog_create_document (OpenTemplateDialog* self, const gchar* contents);
gchar* templates_get_default_template_contents (Templates* self, GtkTreePath* path);
gchar* templates_get_personal_template_contents (Templates* self, GtkTreePath* path);
GType document_tab_get_type (void) G_GNUC_CONST;
DocumentTab* main_window_create_tab (MainWindow* self, gboolean jump_to);
GType document_get_type (void) G_GNUC_CONST;
Document* document_tab_get_document (DocumentTab* self);
void document_set_contents (Document* self, const gchar* contents);
static void open_template_dialog_finalize (OpenTemplateDialog* obj);
GType create_template_dialog_get_type (void) G_GNUC_CONST;
enum  {
	CREATE_TEMPLATE_DIALOG_DUMMY_PROPERTY
};
CreateTemplateDialog* create_template_dialog_new (MainWindow* parent);
CreateTemplateDialog* create_template_dialog_construct (GType object_type, MainWindow* parent);
DocumentTab* main_window_get_active_tab (MainWindow* self);
static void create_template_dialog_run_me (CreateTemplateDialog* self, MainWindow* parent, GtkEntry* entry, GtkTreeView* templates_list);
Document* main_window_get_active_document (MainWindow* self);
gchar* templates_get_icon_id (Templates* self, GtkTreePath* default_template_path);
void templates_create_personal_template (Templates* self, const gchar* name, const gchar* icon_id, const gchar* contents);
GType delete_template_dialog_get_type (void) G_GNUC_CONST;
enum  {
	DELETE_TEMPLATE_DIALOG_DUMMY_PROPERTY
};
DeleteTemplateDialog* delete_template_dialog_new (MainWindow* parent);
DeleteTemplateDialog* delete_template_dialog_construct (GType object_type, MainWindow* parent);
static void delete_template_dialog_run_me (DeleteTemplateDialog* self, GtkTreeView* templates_list);
void templates_delete_personal_template (Templates* self, GtkTreePath* template_path);
void templates_save_rc_file (Templates* self);


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


OpenTemplateDialog* open_template_dialog_construct (GType object_type, MainWindow* main_window) {
	OpenTemplateDialog* self = NULL;
	MainWindow* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	MainWindow* _tmp2_ = NULL;
	GtkDialog* _tmp3_ = NULL;
	GtkBox* content_area = NULL;
	GtkDialog* _tmp4_ = NULL;
	GtkBox* _tmp5_ = NULL;
	GtkBox* _tmp6_ = NULL;
	GtkGrid* hgrid = NULL;
	GtkGrid* _tmp7_ = NULL;
	Templates* templates = NULL;
	Templates* _tmp8_ = NULL;
	GtkTreeView* _tmp9_ = NULL;
	GtkScrolledWindow* scrollbar = NULL;
	GtkTreeView* _tmp10_ = NULL;
	GtkScrolledWindow* _tmp11_ = NULL;
	GtkScrolledWindow* _tmp12_ = NULL;
	GtkScrolledWindow* _tmp13_ = NULL;
	GtkWidget* component = NULL;
	const gchar* _tmp14_ = NULL;
	GtkScrolledWindow* _tmp15_ = NULL;
	GtkGrid* _tmp16_ = NULL;
	GtkWidget* _tmp17_ = NULL;
	GtkTreeView* _tmp18_ = NULL;
	GtkTreeView* _tmp19_ = NULL;
	GtkScrolledWindow* _tmp20_ = NULL;
	GtkScrolledWindow* _tmp21_ = NULL;
	GtkScrolledWindow* _tmp22_ = NULL;
	const gchar* _tmp23_ = NULL;
	GtkScrolledWindow* _tmp24_ = NULL;
	GtkGrid* _tmp25_ = NULL;
	GtkWidget* _tmp26_ = NULL;
	GtkDialog* _tmp27_ = NULL;
	g_return_val_if_fail (main_window != NULL, NULL);
	self = (OpenTemplateDialog*) g_type_create_instance (object_type);
	_tmp0_ = main_window;
	self->priv->_main_window = _tmp0_;
	_tmp1_ = _ ("New File...");
	_tmp2_ = main_window;
	_tmp3_ = (GtkDialog*) gtk_dialog_new_with_buttons (_tmp1_, (GtkWindow*) _tmp2_, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->_dialog);
	self->priv->_dialog = _tmp3_;
	_tmp4_ = self->priv->_dialog;
	_tmp5_ = (GtkBox*) gtk_dialog_get_content_area (_tmp4_);
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, GTK_TYPE_BOX) ? ((GtkBox*) _tmp5_) : NULL);
	content_area = _tmp6_;
	_tmp7_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp7_);
	hgrid = _tmp7_;
	gtk_orientable_set_orientation ((GtkOrientable*) hgrid, GTK_ORIENTATION_HORIZONTAL);
	gtk_grid_set_column_spacing (hgrid, (guint) 10);
	gtk_box_pack_start (content_area, (GtkWidget*) hgrid, TRUE, TRUE, (guint) 0);
	_tmp8_ = templates_get_default ();
	templates = _tmp8_;
	_tmp9_ = templates_get_default_templates_list (templates);
	_g_object_unref0 (self->priv->_default_templates);
	self->priv->_default_templates = _tmp9_;
	_tmp10_ = self->priv->_default_templates;
	_tmp11_ = utils_add_scrollbar ((GtkWidget*) _tmp10_);
	scrollbar = _tmp11_;
	_tmp12_ = scrollbar;
	gtk_scrolled_window_set_shadow_type (_tmp12_, GTK_SHADOW_IN);
	_tmp13_ = scrollbar;
	gtk_widget_set_size_request ((GtkWidget*) _tmp13_, 250, 200);
	_tmp14_ = _ ("Default templates");
	_tmp15_ = scrollbar;
	_tmp16_ = utils_get_dialog_component (_tmp14_, (GtkWidget*) _tmp15_);
	component = (GtkWidget*) _tmp16_;
	_tmp17_ = component;
	gtk_container_add ((GtkContainer*) hgrid, _tmp17_);
	_tmp18_ = templates_get_personal_templates_list (templates);
	_g_object_unref0 (self->priv->_personal_templates);
	self->priv->_personal_templates = _tmp18_;
	_tmp19_ = self->priv->_personal_templates;
	_tmp20_ = utils_add_scrollbar ((GtkWidget*) _tmp19_);
	_g_object_unref0 (scrollbar);
	scrollbar = _tmp20_;
	_tmp21_ = scrollbar;
	gtk_scrolled_window_set_shadow_type (_tmp21_, GTK_SHADOW_IN);
	_tmp22_ = scrollbar;
	gtk_widget_set_size_request ((GtkWidget*) _tmp22_, 250, 200);
	_tmp23_ = _ ("Your personal templates");
	_tmp24_ = scrollbar;
	_tmp25_ = utils_get_dialog_component (_tmp23_, (GtkWidget*) _tmp24_);
	_g_object_unref0 (component);
	component = (GtkWidget*) _tmp25_;
	_tmp26_ = component;
	gtk_container_add ((GtkContainer*) hgrid, _tmp26_);
	gtk_widget_show_all ((GtkWidget*) content_area);
	open_template_dialog_connect_to_signals (self);
	open_template_dialog_run_me (self);
	_tmp27_ = self->priv->_dialog;
	gtk_widget_destroy ((GtkWidget*) _tmp27_);
	_g_object_unref0 (component);
	_g_object_unref0 (scrollbar);
	_g_object_unref0 (templates);
	_g_object_unref0 (hgrid);
	_g_object_unref0 (content_area);
	return self;
}


OpenTemplateDialog* open_template_dialog_new (MainWindow* main_window) {
	return open_template_dialog_construct (TYPE_OPEN_TEMPLATE_DIALOG, main_window);
}


static Block33Data* block33_data_ref (Block33Data* _data33_) {
	g_atomic_int_inc (&_data33_->_ref_count_);
	return _data33_;
}


static void block33_data_unref (void * _userdata_) {
	Block33Data* _data33_;
	_data33_ = (Block33Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data33_->_ref_count_)) {
		OpenTemplateDialog * self;
		self = _data33_->self;
		_g_object_unref0 (_data33_->personal_select);
		_g_object_unref0 (_data33_->default_select);
		_open_template_dialog_unref0 (self);
		g_slice_free (Block33Data, _data33_);
	}
}


static void __lambda102_ (Block33Data* _data33_) {
	OpenTemplateDialog * self;
	self = _data33_->self;
	open_template_dialog_on_list_selection_changed (self, _data33_->default_select, _data33_->personal_select);
}


static void ___lambda102__gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self) {
	__lambda102_ (self);
}


static void __lambda103_ (Block33Data* _data33_) {
	OpenTemplateDialog * self;
	self = _data33_->self;
	open_template_dialog_on_list_selection_changed (self, _data33_->personal_select, _data33_->default_select);
}


static void ___lambda103__gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self) {
	__lambda103_ (self);
}


static void __lambda104_ (OpenTemplateDialog* self, GtkTreePath* path) {
	GtkTreePath* _tmp0_ = NULL;
	GtkDialog* _tmp1_ = NULL;
	g_return_if_fail (path != NULL);
	_tmp0_ = path;
	open_template_dialog_open_default_template (self, _tmp0_);
	_tmp1_ = self->priv->_dialog;
	gtk_widget_destroy ((GtkWidget*) _tmp1_);
}


static void ___lambda104__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self) {
	__lambda104_ (self, path);
}


static void __lambda105_ (OpenTemplateDialog* self, GtkTreePath* path) {
	GtkTreePath* _tmp0_ = NULL;
	GtkDialog* _tmp1_ = NULL;
	g_return_if_fail (path != NULL);
	_tmp0_ = path;
	open_template_dialog_open_personal_template (self, _tmp0_);
	_tmp1_ = self->priv->_dialog;
	gtk_widget_destroy ((GtkWidget*) _tmp1_);
}


static void ___lambda105__gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self) {
	__lambda105_ (self, path);
}


static void open_template_dialog_connect_to_signals (OpenTemplateDialog* self) {
	Block33Data* _data33_;
	GtkTreeView* _tmp0_ = NULL;
	GtkTreeSelection* _tmp1_ = NULL;
	GtkTreeSelection* _tmp2_ = NULL;
	GtkTreeView* _tmp3_ = NULL;
	GtkTreeSelection* _tmp4_ = NULL;
	GtkTreeSelection* _tmp5_ = NULL;
	GtkTreeView* _tmp6_ = NULL;
	GtkTreeView* _tmp7_ = NULL;
	g_return_if_fail (self != NULL);
	_data33_ = g_slice_new0 (Block33Data);
	_data33_->_ref_count_ = 1;
	_data33_->self = open_template_dialog_ref (self);
	_tmp0_ = self->priv->_default_templates;
	_tmp1_ = gtk_tree_view_get_selection (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_data33_->default_select = _tmp2_;
	_tmp3_ = self->priv->_personal_templates;
	_tmp4_ = gtk_tree_view_get_selection (_tmp3_);
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_data33_->personal_select = _tmp5_;
	g_signal_connect_data (_data33_->default_select, "changed", (GCallback) ___lambda102__gtk_tree_selection_changed, block33_data_ref (_data33_), (GClosureNotify) block33_data_unref, 0);
	g_signal_connect_data (_data33_->personal_select, "changed", (GCallback) ___lambda103__gtk_tree_selection_changed, block33_data_ref (_data33_), (GClosureNotify) block33_data_unref, 0);
	_tmp6_ = self->priv->_default_templates;
	g_signal_connect (_tmp6_, "row-activated", (GCallback) ___lambda104__gtk_tree_view_row_activated, self);
	_tmp7_ = self->priv->_personal_templates;
	g_signal_connect (_tmp7_, "row-activated", (GCallback) ___lambda105__gtk_tree_view_row_activated, self);
	block33_data_unref (_data33_);
	_data33_ = NULL;
}


static void _gtk_tree_path_free0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL));
}


static void _g_list_free__gtk_tree_path_free0_ (GList* self) {
	g_list_foreach (self, (GFunc) _gtk_tree_path_free0_, NULL);
	g_list_free (self);
}


static void open_template_dialog_on_list_selection_changed (OpenTemplateDialog* self, GtkTreeSelection* select, GtkTreeSelection* other_select) {
	GList* selected_items = NULL;
	GtkTreeSelection* _tmp0_ = NULL;
	GList* _tmp1_ = NULL;
	GList* _tmp2_ = NULL;
	guint _tmp3_ = 0U;
	g_return_if_fail (self != NULL);
	g_return_if_fail (select != NULL);
	g_return_if_fail (other_select != NULL);
	_tmp0_ = select;
	_tmp1_ = gtk_tree_selection_get_selected_rows (_tmp0_, NULL);
	selected_items = _tmp1_;
	_tmp2_ = selected_items;
	_tmp3_ = g_list_length (_tmp2_);
	if (_tmp3_ > ((guint) 0)) {
		GtkTreeSelection* _tmp4_ = NULL;
		_tmp4_ = other_select;
		gtk_tree_selection_unselect_all (_tmp4_);
	}
	__g_list_free__gtk_tree_path_free0_0 (selected_items);
}


static gpointer _gtk_tree_path_copy0 (gpointer self) {
	return self ? gtk_tree_path_copy (self) : NULL;
}


static void open_template_dialog_run_me (OpenTemplateDialog* self) {
	GtkDialog* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	GtkTreeSelection* select = NULL;
	GtkTreeView* _tmp2_ = NULL;
	GtkTreeSelection* _tmp3_ = NULL;
	GtkTreeSelection* _tmp4_ = NULL;
	GList* selected_items = NULL;
	GtkTreeSelection* _tmp5_ = NULL;
	GList* _tmp6_ = NULL;
	GList* _tmp7_ = NULL;
	guint _tmp8_ = 0U;
	GtkTreeView* _tmp13_ = NULL;
	GtkTreeSelection* _tmp14_ = NULL;
	GtkTreeSelection* _tmp15_ = NULL;
	GtkTreeSelection* _tmp16_ = NULL;
	GList* _tmp17_ = NULL;
	GList* _tmp18_ = NULL;
	guint _tmp19_ = 0U;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_dialog;
	_tmp1_ = gtk_dialog_run (_tmp0_);
	if (_tmp1_ != ((gint) GTK_RESPONSE_ACCEPT)) {
		return;
	}
	_tmp2_ = self->priv->_default_templates;
	_tmp3_ = gtk_tree_view_get_selection (_tmp2_);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	select = _tmp4_;
	_tmp5_ = select;
	_tmp6_ = gtk_tree_selection_get_selected_rows (_tmp5_, NULL);
	selected_items = _tmp6_;
	_tmp7_ = selected_items;
	_tmp8_ = g_list_length (_tmp7_);
	if (_tmp8_ > ((guint) 0)) {
		GtkTreePath* path = NULL;
		GList* _tmp9_ = NULL;
		gconstpointer _tmp10_ = NULL;
		GtkTreePath* _tmp11_ = NULL;
		GtkTreePath* _tmp12_ = NULL;
		_tmp9_ = selected_items;
		_tmp10_ = g_list_nth_data (_tmp9_, (guint) 0);
		_tmp11_ = _gtk_tree_path_copy0 ((GtkTreePath*) _tmp10_);
		path = _tmp11_;
		_tmp12_ = path;
		open_template_dialog_open_default_template (self, _tmp12_);
		_gtk_tree_path_free0 (path);
		__g_list_free__gtk_tree_path_free0_0 (selected_items);
		_g_object_unref0 (select);
		return;
	}
	_tmp13_ = self->priv->_personal_templates;
	_tmp14_ = gtk_tree_view_get_selection (_tmp13_);
	_tmp15_ = _g_object_ref0 (_tmp14_);
	_g_object_unref0 (select);
	select = _tmp15_;
	_tmp16_ = select;
	_tmp17_ = gtk_tree_selection_get_selected_rows (_tmp16_, NULL);
	__g_list_free__gtk_tree_path_free0_0 (selected_items);
	selected_items = _tmp17_;
	_tmp18_ = selected_items;
	_tmp19_ = g_list_length (_tmp18_);
	if (_tmp19_ > ((guint) 0)) {
		GtkTreePath* path = NULL;
		GList* _tmp20_ = NULL;
		gconstpointer _tmp21_ = NULL;
		GtkTreePath* _tmp22_ = NULL;
		GtkTreePath* _tmp23_ = NULL;
		_tmp20_ = selected_items;
		_tmp21_ = g_list_nth_data (_tmp20_, (guint) 0);
		_tmp22_ = _gtk_tree_path_copy0 ((GtkTreePath*) _tmp21_);
		path = _tmp22_;
		_tmp23_ = path;
		open_template_dialog_open_personal_template (self, _tmp23_);
		_gtk_tree_path_free0 (path);
		__g_list_free__gtk_tree_path_free0_0 (selected_items);
		_g_object_unref0 (select);
		return;
	}
	open_template_dialog_create_document (self, "");
	__g_list_free__gtk_tree_path_free0_0 (selected_items);
	_g_object_unref0 (select);
}


static void open_template_dialog_open_default_template (OpenTemplateDialog* self, GtkTreePath* path) {
	Templates* templates = NULL;
	Templates* _tmp0_ = NULL;
	GtkTreePath* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	_tmp0_ = templates_get_default ();
	templates = _tmp0_;
	_tmp1_ = path;
	_tmp2_ = templates_get_default_template_contents (templates, _tmp1_);
	_tmp3_ = _tmp2_;
	open_template_dialog_create_document (self, _tmp3_);
	_g_free0 (_tmp3_);
	_g_object_unref0 (templates);
}


static void open_template_dialog_open_personal_template (OpenTemplateDialog* self, GtkTreePath* path) {
	Templates* templates = NULL;
	Templates* _tmp0_ = NULL;
	GtkTreePath* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	_tmp0_ = templates_get_default ();
	templates = _tmp0_;
	_tmp1_ = path;
	_tmp2_ = templates_get_personal_template_contents (templates, _tmp1_);
	_tmp3_ = _tmp2_;
	open_template_dialog_create_document (self, _tmp3_);
	_g_free0 (_tmp3_);
	_g_object_unref0 (templates);
}


static void open_template_dialog_create_document (OpenTemplateDialog* self, const gchar* contents) {
	DocumentTab* tab = NULL;
	MainWindow* _tmp0_ = NULL;
	DocumentTab* _tmp1_ = NULL;
	Document* _tmp2_ = NULL;
	Document* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (contents != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_create_tab (_tmp0_, TRUE);
	tab = _tmp1_;
	_tmp2_ = document_tab_get_document (tab);
	_tmp3_ = _tmp2_;
	_tmp4_ = contents;
	document_set_contents (_tmp3_, _tmp4_);
	_g_object_unref0 (tab);
}


static void value_open_template_dialog_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


static void value_open_template_dialog_free_value (GValue* value) {
	if (value->data[0].v_pointer) {
		open_template_dialog_unref (value->data[0].v_pointer);
	}
}


static void value_open_template_dialog_copy_value (const GValue* src_value, GValue* dest_value) {
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = open_template_dialog_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


static gpointer value_open_template_dialog_peek_pointer (const GValue* value) {
	return value->data[0].v_pointer;
}


static gchar* value_open_template_dialog_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		OpenTemplateDialog* object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = open_template_dialog_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* value_open_template_dialog_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	OpenTemplateDialog** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = open_template_dialog_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* param_spec_open_template_dialog (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ParamSpecOpenTemplateDialog* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_OPEN_TEMPLATE_DIALOG), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}


gpointer value_get_open_template_dialog (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_OPEN_TEMPLATE_DIALOG), NULL);
	return value->data[0].v_pointer;
}


void value_set_open_template_dialog (GValue* value, gpointer v_object) {
	OpenTemplateDialog* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_OPEN_TEMPLATE_DIALOG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_OPEN_TEMPLATE_DIALOG));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		open_template_dialog_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		open_template_dialog_unref (old);
	}
}


void value_take_open_template_dialog (GValue* value, gpointer v_object) {
	OpenTemplateDialog* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_OPEN_TEMPLATE_DIALOG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_OPEN_TEMPLATE_DIALOG));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		open_template_dialog_unref (old);
	}
}


static void open_template_dialog_class_init (OpenTemplateDialogClass * klass) {
	open_template_dialog_parent_class = g_type_class_peek_parent (klass);
	OPEN_TEMPLATE_DIALOG_CLASS (klass)->finalize = open_template_dialog_finalize;
	g_type_class_add_private (klass, sizeof (OpenTemplateDialogPrivate));
}


static void open_template_dialog_instance_init (OpenTemplateDialog * self) {
	self->priv = OPEN_TEMPLATE_DIALOG_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void open_template_dialog_finalize (OpenTemplateDialog* obj) {
	OpenTemplateDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_OPEN_TEMPLATE_DIALOG, OpenTemplateDialog);
	_g_object_unref0 (self->priv->_dialog);
	_g_object_unref0 (self->priv->_default_templates);
	_g_object_unref0 (self->priv->_personal_templates);
}


GType open_template_dialog_get_type (void) {
	static volatile gsize open_template_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&open_template_dialog_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { value_open_template_dialog_init, value_open_template_dialog_free_value, value_open_template_dialog_copy_value, value_open_template_dialog_peek_pointer, "p", value_open_template_dialog_collect_value, "p", value_open_template_dialog_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (OpenTemplateDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) open_template_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OpenTemplateDialog), 0, (GInstanceInitFunc) open_template_dialog_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType open_template_dialog_type_id;
		open_template_dialog_type_id = g_type_register_fundamental (g_type_fundamental_next (), "OpenTemplateDialog", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&open_template_dialog_type_id__volatile, open_template_dialog_type_id);
	}
	return open_template_dialog_type_id__volatile;
}


gpointer open_template_dialog_ref (gpointer instance) {
	OpenTemplateDialog* self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


void open_template_dialog_unref (gpointer instance) {
	OpenTemplateDialog* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		OPEN_TEMPLATE_DIALOG_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


CreateTemplateDialog* create_template_dialog_construct (GType object_type, MainWindow* parent) {
	CreateTemplateDialog * self = NULL;
	MainWindow* _tmp0_ = NULL;
	DocumentTab* _tmp1_ = NULL;
	DocumentTab* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	MainWindow* _tmp4_ = NULL;
	GtkBox* content_area = NULL;
	GtkBox* _tmp5_ = NULL;
	GtkBox* _tmp6_ = NULL;
	GtkEntry* entry = NULL;
	GtkEntry* _tmp7_ = NULL;
	GtkWidget* component = NULL;
	const gchar* _tmp8_ = NULL;
	GtkGrid* _tmp9_ = NULL;
	GtkWidget* _tmp10_ = NULL;
	Templates* templates = NULL;
	Templates* _tmp11_ = NULL;
	GtkTreeView* templates_list = NULL;
	GtkTreeView* _tmp12_ = NULL;
	GtkScrolledWindow* scrollbar = NULL;
	GtkScrolledWindow* _tmp13_ = NULL;
	const gchar* _tmp14_ = NULL;
	GtkGrid* _tmp15_ = NULL;
	GtkWidget* _tmp16_ = NULL;
	MainWindow* _tmp17_ = NULL;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (CreateTemplateDialog*) g_object_new (object_type, NULL);
	_tmp0_ = parent;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	g_return_val_if_fail (_tmp2_ != NULL, NULL);
	_tmp3_ = _ ("New Template...");
	gtk_window_set_title ((GtkWindow*) self, _tmp3_);
	_tmp4_ = parent;
	gtk_window_set_transient_for ((GtkWindow*) self, (GtkWindow*) _tmp4_);
	gtk_window_set_destroy_with_parent ((GtkWindow*) self, TRUE);
	gtk_dialog_add_button ((GtkDialog*) self, GTK_STOCK_CANCEL, (gint) GTK_RESPONSE_REJECT);
	gtk_dialog_add_button ((GtkDialog*) self, GTK_STOCK_OK, (gint) GTK_RESPONSE_ACCEPT);
	_tmp5_ = (GtkBox*) gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, GTK_TYPE_BOX) ? ((GtkBox*) _tmp5_) : NULL);
	content_area = _tmp6_;
	gtk_box_set_homogeneous (content_area, FALSE);
	_tmp7_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp7_);
	entry = _tmp7_;
	gtk_widget_set_hexpand ((GtkWidget*) entry, TRUE);
	_tmp8_ = _ ("Name of the new template");
	_tmp9_ = utils_get_dialog_component (_tmp8_, (GtkWidget*) entry);
	component = (GtkWidget*) _tmp9_;
	_tmp10_ = component;
	gtk_box_pack_start (content_area, _tmp10_, FALSE, TRUE, (guint) 0);
	_tmp11_ = templates_get_default ();
	templates = _tmp11_;
	_tmp12_ = templates_get_default_templates_list (templates);
	templates_list = _tmp12_;
	_tmp13_ = utils_add_scrollbar ((GtkWidget*) templates_list);
	scrollbar = _tmp13_;
	gtk_scrolled_window_set_shadow_type (scrollbar, GTK_SHADOW_IN);
	gtk_widget_set_size_request ((GtkWidget*) scrollbar, 250, 200);
	_tmp14_ = _ ("Choose an icon");
	_tmp15_ = utils_get_dialog_component (_tmp14_, (GtkWidget*) scrollbar);
	_g_object_unref0 (component);
	component = (GtkWidget*) _tmp15_;
	_tmp16_ = component;
	gtk_box_pack_start (content_area, _tmp16_, TRUE, TRUE, (guint) 0);
	gtk_widget_show_all ((GtkWidget*) content_area);
	_tmp17_ = parent;
	create_template_dialog_run_me (self, _tmp17_, entry, templates_list);
	_g_object_unref0 (scrollbar);
	_g_object_unref0 (templates_list);
	_g_object_unref0 (templates);
	_g_object_unref0 (component);
	_g_object_unref0 (entry);
	_g_object_unref0 (content_area);
	return self;
}


CreateTemplateDialog* create_template_dialog_new (MainWindow* parent) {
	return create_template_dialog_construct (TYPE_CREATE_TEMPLATE_DIALOG, parent);
}


static void create_template_dialog_run_me (CreateTemplateDialog* self, MainWindow* parent, GtkEntry* entry, GtkTreeView* templates_list) {
	Templates* templates = NULL;
	Templates* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (parent != NULL);
	g_return_if_fail (entry != NULL);
	g_return_if_fail (templates_list != NULL);
	_tmp0_ = templates_get_default ();
	templates = _tmp0_;
	while (TRUE) {
		gint _tmp1_ = 0;
		GtkEntry* _tmp2_ = NULL;
		guint _tmp3_ = 0U;
		guint _tmp4_ = 0U;
		GtkTreeSelection* select = NULL;
		GtkTreeView* _tmp5_ = NULL;
		GtkTreeSelection* _tmp6_ = NULL;
		GtkTreeSelection* _tmp7_ = NULL;
		GList* selected_items = NULL;
		GtkTreeSelection* _tmp8_ = NULL;
		GList* _tmp9_ = NULL;
		GList* _tmp10_ = NULL;
		guint _tmp11_ = 0U;
		GtkTextIter start = {0};
		GtkTextIter end = {0};
		MainWindow* _tmp12_ = NULL;
		Document* _tmp13_ = NULL;
		Document* _tmp14_ = NULL;
		GtkTextIter _tmp15_ = {0};
		GtkTextIter _tmp16_ = {0};
		gchar* contents = NULL;
		MainWindow* _tmp17_ = NULL;
		Document* _tmp18_ = NULL;
		Document* _tmp19_ = NULL;
		GtkTextIter _tmp20_ = {0};
		GtkTextIter _tmp21_ = {0};
		gchar* _tmp22_ = NULL;
		GtkTreePath* path = NULL;
		GList* _tmp23_ = NULL;
		gconstpointer _tmp24_ = NULL;
		GtkTreePath* _tmp25_ = NULL;
		gchar* icon_id = NULL;
		Templates* _tmp26_ = NULL;
		GtkTreePath* _tmp27_ = NULL;
		gchar* _tmp28_ = NULL;
		Templates* _tmp29_ = NULL;
		GtkEntry* _tmp30_ = NULL;
		const gchar* _tmp31_ = NULL;
		const gchar* _tmp32_ = NULL;
		const gchar* _tmp33_ = NULL;
		const gchar* _tmp34_ = NULL;
		_tmp1_ = gtk_dialog_run ((GtkDialog*) self);
		if (!(_tmp1_ == ((gint) GTK_RESPONSE_ACCEPT))) {
			break;
		}
		_tmp2_ = entry;
		_tmp3_ = gtk_entry_get_text_length (_tmp2_);
		_tmp4_ = _tmp3_;
		if (_tmp4_ == ((guint) 0)) {
			continue;
		}
		_tmp5_ = templates_list;
		_tmp6_ = gtk_tree_view_get_selection (_tmp5_);
		_tmp7_ = _g_object_ref0 (_tmp6_);
		select = _tmp7_;
		_tmp8_ = select;
		_tmp9_ = gtk_tree_selection_get_selected_rows (_tmp8_, NULL);
		selected_items = _tmp9_;
		_tmp10_ = selected_items;
		_tmp11_ = g_list_length (_tmp10_);
		if (_tmp11_ == ((guint) 0)) {
			__g_list_free__gtk_tree_path_free0_0 (selected_items);
			_g_object_unref0 (select);
			continue;
		}
		_tmp12_ = parent;
		_tmp13_ = main_window_get_active_document (_tmp12_);
		_tmp14_ = _tmp13_;
		gtk_text_buffer_get_bounds ((GtkTextBuffer*) _tmp14_, &_tmp15_, &_tmp16_);
		start = _tmp15_;
		end = _tmp16_;
		_tmp17_ = parent;
		_tmp18_ = main_window_get_active_document (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp20_ = start;
		_tmp21_ = end;
		_tmp22_ = gtk_text_buffer_get_text ((GtkTextBuffer*) _tmp19_, &_tmp20_, &_tmp21_, FALSE);
		contents = _tmp22_;
		_tmp23_ = selected_items;
		_tmp24_ = g_list_nth_data (_tmp23_, (guint) 0);
		_tmp25_ = _gtk_tree_path_copy0 ((GtkTreePath*) _tmp24_);
		path = _tmp25_;
		_tmp26_ = templates;
		_tmp27_ = path;
		_tmp28_ = templates_get_icon_id (_tmp26_, _tmp27_);
		icon_id = _tmp28_;
		_tmp29_ = templates;
		_tmp30_ = entry;
		_tmp31_ = gtk_entry_get_text (_tmp30_);
		_tmp32_ = _tmp31_;
		_tmp33_ = icon_id;
		_tmp34_ = contents;
		templates_create_personal_template (_tmp29_, _tmp32_, _tmp33_, _tmp34_);
		_g_free0 (icon_id);
		_gtk_tree_path_free0 (path);
		_g_free0 (contents);
		__g_list_free__gtk_tree_path_free0_0 (selected_items);
		_g_object_unref0 (select);
		break;
	}
	_g_object_unref0 (templates);
}


static void create_template_dialog_class_init (CreateTemplateDialogClass * klass) {
	create_template_dialog_parent_class = g_type_class_peek_parent (klass);
}


static void create_template_dialog_instance_init (CreateTemplateDialog * self) {
}


GType create_template_dialog_get_type (void) {
	static volatile gsize create_template_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&create_template_dialog_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (CreateTemplateDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) create_template_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CreateTemplateDialog), 0, (GInstanceInitFunc) create_template_dialog_instance_init, NULL };
		GType create_template_dialog_type_id;
		create_template_dialog_type_id = g_type_register_static (GTK_TYPE_DIALOG, "CreateTemplateDialog", &g_define_type_info, 0);
		g_once_init_leave (&create_template_dialog_type_id__volatile, create_template_dialog_type_id);
	}
	return create_template_dialog_type_id__volatile;
}


DeleteTemplateDialog* delete_template_dialog_construct (GType object_type, MainWindow* parent) {
	DeleteTemplateDialog * self = NULL;
	const gchar* _tmp0_ = NULL;
	MainWindow* _tmp1_ = NULL;
	Templates* templates = NULL;
	Templates* _tmp2_ = NULL;
	GtkTreeView* templates_list = NULL;
	GtkTreeView* _tmp3_ = NULL;
	GtkTreeSelection* select = NULL;
	GtkTreeSelection* _tmp4_ = NULL;
	GtkTreeSelection* _tmp5_ = NULL;
	GtkScrolledWindow* scrollbar = NULL;
	GtkScrolledWindow* _tmp6_ = NULL;
	GtkWidget* component = NULL;
	const gchar* _tmp7_ = NULL;
	GtkGrid* _tmp8_ = NULL;
	GtkBox* content_area = NULL;
	GtkBox* _tmp9_ = NULL;
	GtkBox* _tmp10_ = NULL;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (DeleteTemplateDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _ ("Delete Template(s)...");
	gtk_window_set_title ((GtkWindow*) self, _tmp0_);
	gtk_dialog_add_button ((GtkDialog*) self, GTK_STOCK_DELETE, (gint) GTK_RESPONSE_ACCEPT);
	gtk_dialog_add_button ((GtkDialog*) self, GTK_STOCK_CLOSE, (gint) GTK_RESPONSE_REJECT);
	_tmp1_ = parent;
	gtk_window_set_transient_for ((GtkWindow*) self, (GtkWindow*) _tmp1_);
	gtk_window_set_destroy_with_parent ((GtkWindow*) self, TRUE);
	_tmp2_ = templates_get_default ();
	templates = _tmp2_;
	_tmp3_ = templates_get_personal_templates_list (templates);
	templates_list = _tmp3_;
	_tmp4_ = gtk_tree_view_get_selection (templates_list);
	_tmp5_ = _g_object_ref0 (_tmp4_);
	select = _tmp5_;
	gtk_tree_selection_set_mode (select, GTK_SELECTION_MULTIPLE);
	_tmp6_ = utils_add_scrollbar ((GtkWidget*) templates_list);
	scrollbar = _tmp6_;
	gtk_scrolled_window_set_shadow_type (scrollbar, GTK_SHADOW_IN);
	gtk_widget_set_size_request ((GtkWidget*) scrollbar, 250, 150);
	_tmp7_ = _ ("Personal templates");
	_tmp8_ = utils_get_dialog_component (_tmp7_, (GtkWidget*) scrollbar);
	component = (GtkWidget*) _tmp8_;
	_tmp9_ = (GtkBox*) gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp9_, GTK_TYPE_BOX) ? ((GtkBox*) _tmp9_) : NULL);
	content_area = _tmp10_;
	gtk_box_pack_start (content_area, component, TRUE, TRUE, (guint) 0);
	gtk_widget_show_all ((GtkWidget*) content_area);
	delete_template_dialog_run_me (self, templates_list);
	_g_object_unref0 (content_area);
	_g_object_unref0 (component);
	_g_object_unref0 (scrollbar);
	_g_object_unref0 (select);
	_g_object_unref0 (templates_list);
	_g_object_unref0 (templates);
	return self;
}


DeleteTemplateDialog* delete_template_dialog_new (MainWindow* parent) {
	return delete_template_dialog_construct (TYPE_DELETE_TEMPLATE_DIALOG, parent);
}


static void delete_template_dialog_run_me (DeleteTemplateDialog* self, GtkTreeView* templates_list) {
	Templates* templates = NULL;
	Templates* _tmp0_ = NULL;
	gboolean template_deleted = FALSE;
	gboolean _tmp20_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (templates_list != NULL);
	_tmp0_ = templates_get_default ();
	templates = _tmp0_;
	template_deleted = FALSE;
	while (TRUE) {
		gint _tmp1_ = 0;
		GtkTreeSelection* select = NULL;
		GtkTreeView* _tmp2_ = NULL;
		GtkTreeSelection* _tmp3_ = NULL;
		GtkTreeSelection* _tmp4_ = NULL;
		GList* selected_items = NULL;
		GtkTreeSelection* _tmp5_ = NULL;
		GList* _tmp6_ = NULL;
		guint nb_selected_items = 0U;
		GList* _tmp7_ = NULL;
		guint _tmp8_ = 0U;
		_tmp1_ = gtk_dialog_run ((GtkDialog*) self);
		if (!(_tmp1_ == ((gint) GTK_RESPONSE_ACCEPT))) {
			break;
		}
		_tmp2_ = templates_list;
		_tmp3_ = gtk_tree_view_get_selection (_tmp2_);
		_tmp4_ = _g_object_ref0 (_tmp3_);
		select = _tmp4_;
		_tmp5_ = select;
		_tmp6_ = gtk_tree_selection_get_selected_rows (_tmp5_, NULL);
		selected_items = _tmp6_;
		_tmp7_ = selected_items;
		_tmp8_ = g_list_length (_tmp7_);
		nb_selected_items = _tmp8_;
		{
			gint item_num = 0;
			item_num = 0;
			{
				gboolean _tmp9_ = FALSE;
				_tmp9_ = TRUE;
				while (TRUE) {
					gboolean _tmp10_ = FALSE;
					gint _tmp12_ = 0;
					guint _tmp13_ = 0U;
					GtkTreePath* path = NULL;
					GList* _tmp14_ = NULL;
					gint _tmp15_ = 0;
					gconstpointer _tmp16_ = NULL;
					GtkTreePath* _tmp17_ = NULL;
					Templates* _tmp18_ = NULL;
					GtkTreePath* _tmp19_ = NULL;
					_tmp10_ = _tmp9_;
					if (!_tmp10_) {
						gint _tmp11_ = 0;
						_tmp11_ = item_num;
						item_num = _tmp11_ + 1;
					}
					_tmp9_ = FALSE;
					_tmp12_ = item_num;
					_tmp13_ = nb_selected_items;
					if (!(((guint) _tmp12_) < _tmp13_)) {
						break;
					}
					_tmp14_ = selected_items;
					_tmp15_ = item_num;
					_tmp16_ = g_list_nth_data (_tmp14_, (guint) _tmp15_);
					_tmp17_ = _gtk_tree_path_copy0 ((GtkTreePath*) _tmp16_);
					path = _tmp17_;
					_tmp18_ = templates;
					_tmp19_ = path;
					templates_delete_personal_template (_tmp18_, _tmp19_);
					template_deleted = TRUE;
					_gtk_tree_path_free0 (path);
				}
			}
		}
		__g_list_free__gtk_tree_path_free0_0 (selected_items);
		_g_object_unref0 (select);
	}
	_tmp20_ = template_deleted;
	if (_tmp20_) {
		Templates* _tmp21_ = NULL;
		_tmp21_ = templates;
		templates_save_rc_file (_tmp21_);
	}
	_g_object_unref0 (templates);
}


static void delete_template_dialog_class_init (DeleteTemplateDialogClass * klass) {
	delete_template_dialog_parent_class = g_type_class_peek_parent (klass);
}


static void delete_template_dialog_instance_init (DeleteTemplateDialog * self) {
}


GType delete_template_dialog_get_type (void) {
	static volatile gsize delete_template_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&delete_template_dialog_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DeleteTemplateDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) delete_template_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DeleteTemplateDialog), 0, (GInstanceInitFunc) delete_template_dialog_instance_init, NULL };
		GType delete_template_dialog_type_id;
		delete_template_dialog_type_id = g_type_register_static (GTK_TYPE_DIALOG, "DeleteTemplateDialog", &g_define_type_info, 0);
		g_once_init_leave (&delete_template_dialog_type_id__volatile, delete_template_dialog_type_id);
	}
	return delete_template_dialog_type_id__volatile;
}



