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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <libxml/HTMLtree.h>
#include <libxml/HTMLparser.h>
#include <libxml/tree.h>
#include <libxml/parser.h>

#define TOOTLE_WIDGETS_TYPE_MARKUP_VIEW (tootle_widgets_markup_view_get_type ())
#define TOOTLE_WIDGETS_MARKUP_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_WIDGETS_TYPE_MARKUP_VIEW, TootleWidgetsMarkupView))
#define TOOTLE_WIDGETS_MARKUP_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_WIDGETS_TYPE_MARKUP_VIEW, TootleWidgetsMarkupViewClass))
#define TOOTLE_WIDGETS_IS_MARKUP_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_WIDGETS_TYPE_MARKUP_VIEW))
#define TOOTLE_WIDGETS_IS_MARKUP_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_WIDGETS_TYPE_MARKUP_VIEW))
#define TOOTLE_WIDGETS_MARKUP_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_WIDGETS_TYPE_MARKUP_VIEW, TootleWidgetsMarkupViewClass))

typedef struct _TootleWidgetsMarkupView TootleWidgetsMarkupView;
typedef struct _TootleWidgetsMarkupViewClass TootleWidgetsMarkupViewClass;
typedef struct _TootleWidgetsMarkupViewPrivate TootleWidgetsMarkupViewPrivate;
enum  {
	TOOTLE_WIDGETS_MARKUP_VIEW_0_PROPERTY,
	TOOTLE_WIDGETS_MARKUP_VIEW_CONTENT_PROPERTY,
	TOOTLE_WIDGETS_MARKUP_VIEW_SELECTABLE_PROPERTY,
	TOOTLE_WIDGETS_MARKUP_VIEW_NUM_PROPERTIES
};
static GParamSpec* tootle_widgets_markup_view_properties[TOOTLE_WIDGETS_MARKUP_VIEW_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
typedef void (*TootleWidgetsMarkupViewNodeFn) (xmlNode* node, gpointer user_data);
typedef void (*TootleWidgetsMarkupViewNodeHandlerFn) (TootleWidgetsMarkupView* view, xmlNode* node, gpointer user_data);
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block28Data Block28Data;

#define TOOTLE_WIDGETS_TYPE_RICH_LABEL (tootle_widgets_rich_label_get_type ())
#define TOOTLE_WIDGETS_RICH_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_WIDGETS_TYPE_RICH_LABEL, TootleWidgetsRichLabel))
#define TOOTLE_WIDGETS_RICH_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_WIDGETS_TYPE_RICH_LABEL, TootleWidgetsRichLabelClass))
#define TOOTLE_WIDGETS_IS_RICH_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_WIDGETS_TYPE_RICH_LABEL))
#define TOOTLE_WIDGETS_IS_RICH_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_WIDGETS_TYPE_RICH_LABEL))
#define TOOTLE_WIDGETS_RICH_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_WIDGETS_TYPE_RICH_LABEL, TootleWidgetsRichLabelClass))

typedef struct _TootleWidgetsRichLabel TootleWidgetsRichLabel;
typedef struct _TootleWidgetsRichLabelClass TootleWidgetsRichLabelClass;
typedef enum  {
	TOOTLE_MARKUP_POLICY_DISALLOW,
	TOOTLE_MARKUP_POLICY_ALLOW,
	TOOTLE_MARKUP_POLICY_TRUST
} TootleMarkupPolicy;

#define TOOTLE_TYPE_MARKUP_POLICY (tootle_markup_policy_get_type ())
typedef struct _Block29Data Block29Data;

struct _TootleWidgetsMarkupView {
	GtkBox parent_instance;
	TootleWidgetsMarkupViewPrivate * priv;
};

struct _TootleWidgetsMarkupViewClass {
	GtkBoxClass parent_class;
};

struct _TootleWidgetsMarkupViewPrivate {
	gchar* current_chunk;
	gchar* _content;
	gboolean _selectable;
};

struct _Block28Data {
	int _ref_count_;
	TootleWidgetsMarkupView* v;
	TootleWidgetsMarkupViewNodeHandlerFn handler;
	gpointer handler_target;
	GDestroyNotify handler_target_destroy_notify;
};

struct _Block29Data {
	int _ref_count_;
	gchar* text;
};

static gint TootleWidgetsMarkupView_private_offset;
static gpointer tootle_widgets_markup_view_parent_class = NULL;

GType tootle_widgets_markup_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleWidgetsMarkupView, g_object_unref)
static void tootle_widgets_markup_view_update_content (TootleWidgetsMarkupView* self,
                                                const gchar* content);
static void __lambda29_ (TootleWidgetsMarkupView* self,
                  GtkWidget* w);
static void ___lambda29__gfunc (gconstpointer data,
                         gpointer self);
void tootle_widgets_markup_view_default_handler (TootleWidgetsMarkupView* v,
                                                 xmlNode* root);
static void tootle_widgets_markup_view_traverse (xmlNode* root,
                                          TootleWidgetsMarkupViewNodeFn cb,
                                          gpointer cb_target,
                                          GDestroyNotify cb_target_destroy_notify);
static void tootle_widgets_markup_view_traverse_and_handle (TootleWidgetsMarkupView* v,
                                                     xmlNode* root,
                                                     TootleWidgetsMarkupViewNodeHandlerFn handler,
                                                     gpointer handler_target,
                                                     GDestroyNotify handler_target_destroy_notify);
static Block28Data* block28_data_ref (Block28Data* _data28_);
static void block28_data_unref (void * _userdata_);
static void __lambda30_ (Block28Data* _data28_,
                  xmlNode* node);
static void ___lambda30__tootle_widgets_markup_view_node_fn (xmlNode* node,
                                                      gpointer self);
static void tootle_widgets_markup_view_commit_chunk (TootleWidgetsMarkupView* self);
GType tootle_widgets_rich_label_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleWidgetsRichLabel, g_object_unref)
GType tootle_markup_policy_get_type (void) G_GNUC_CONST ;
TootleWidgetsRichLabel* tootle_widgets_rich_label_new (const gchar* text);
TootleWidgetsRichLabel* tootle_widgets_rich_label_construct (GType object_type,
                                                             const gchar* text);
void tootle_widgets_rich_label_set_markup (TootleWidgetsRichLabel* self,
                                           TootleMarkupPolicy value);
static void tootle_widgets_markup_view_write_chunk (TootleWidgetsMarkupView* self,
                                             const gchar* chunk);
static void _tootle_widgets_markup_view_default_handler_tootle_widgets_markup_view_node_handler_fn (TootleWidgetsMarkupView* view,
                                                                                             xmlNode* node,
                                                                                             gpointer self);
static Block29Data* block29_data_ref (Block29Data* _data29_);
static void block29_data_unref (void * _userdata_);
static void ___lambda31_ (Block29Data* _data29_,
                   xmlNode* node);
static void ____lambda31__tootle_widgets_markup_view_node_fn (xmlNode* node,
                                                       gpointer self);
TootleWidgetsMarkupView* tootle_widgets_markup_view_new (void);
TootleWidgetsMarkupView* tootle_widgets_markup_view_construct (GType object_type);
const gchar* tootle_widgets_markup_view_get_content (TootleWidgetsMarkupView* self);
void tootle_widgets_markup_view_set_content (TootleWidgetsMarkupView* self,
                                             const gchar* value);
gboolean tootle_widgets_markup_view_get_selectable (TootleWidgetsMarkupView* self);
void tootle_widgets_markup_view_set_selectable (TootleWidgetsMarkupView* self,
                                                gboolean value);
static void _tootle_widgets_markup_view_selectable___lambda32_ (TootleWidgetsMarkupView* self,
                                                         GtkWidget* w);
static void __tootle_widgets_markup_view_selectable___lambda32__gfunc (gconstpointer data,
                                                                gpointer self);
static GObject * tootle_widgets_markup_view_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static void tootle_widgets_markup_view_finalize (GObject * obj);
static GType tootle_widgets_markup_view_get_type_once (void);
static void _vala_tootle_widgets_markup_view_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_tootle_widgets_markup_view_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
tootle_widgets_markup_view_get_instance_private (TootleWidgetsMarkupView* self)
{
	return G_STRUCT_MEMBER_P (self, TootleWidgetsMarkupView_private_offset);
}

static void
__lambda29_ (TootleWidgetsMarkupView* self,
             GtkWidget* w)
{
	g_return_if_fail (w != NULL);
	gtk_widget_destroy (w);
}

static void
___lambda29__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda29_ ((TootleWidgetsMarkupView*) self, (GtkWidget*) data);
}

static void
tootle_widgets_markup_view_update_content (TootleWidgetsMarkupView* self,
                                           const gchar* content)
{
	GList* _tmp0_;
	GList* _tmp1_;
	xmlDoc* doc = NULL;
	xmlDoc* _tmp2_;
	xmlDoc* _tmp3_;
	xmlDoc* _tmp8_;
	GList* _tmp9_;
	GList* _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (content != NULL);
	_g_free0 (self->priv->current_chunk);
	self->priv->current_chunk = NULL;
	_tmp0_ = gtk_container_get_children ((GtkContainer*) self);
	_tmp1_ = _tmp0_;
	g_list_foreach (_tmp1_, ___lambda29__gfunc, self);
	(_tmp1_ == NULL) ? NULL : (_tmp1_ = (g_list_free (_tmp1_), NULL));
	_tmp2_ = htmlReadDoc ((xmlChar*) content, "", "utf8", 0);
	doc = _tmp2_;
	_tmp3_ = doc;
	if (_tmp3_ != NULL) {
		xmlNode* root = NULL;
		xmlDoc* _tmp4_;
		xmlNode* _tmp5_;
		xmlNode* _tmp6_;
		_tmp4_ = doc;
		_tmp5_ = xmlDocGetRootElement (_tmp4_);
		root = _tmp5_;
		_tmp6_ = root;
		if (_tmp6_ != NULL) {
			xmlNode* _tmp7_;
			_tmp7_ = root;
			tootle_widgets_markup_view_default_handler (self, _tmp7_);
		}
	}
	_tmp8_ = doc;
	xmlFreeDoc (_tmp8_);
	_tmp9_ = gtk_container_get_children ((GtkContainer*) self);
	_tmp10_ = _tmp9_;
	gtk_widget_set_visible ((GtkWidget*) self, g_list_length (_tmp10_) > ((guint) 0));
	(_tmp10_ == NULL) ? NULL : (_tmp10_ = (g_list_free (_tmp10_), NULL));
}

static void
tootle_widgets_markup_view_traverse (xmlNode* root,
                                     TootleWidgetsMarkupViewNodeFn cb,
                                     gpointer cb_target,
                                     GDestroyNotify cb_target_destroy_notify)
{
	{
		xmlNode* iter = NULL;
		xmlNode* _tmp0_;
		_tmp0_ = root->children;
		iter = _tmp0_;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp4_;
				xmlNode* _tmp5_;
				if (!_tmp1_) {
					xmlNode* _tmp2_;
					xmlNode* _tmp3_;
					_tmp2_ = iter;
					_tmp3_ = _tmp2_->next;
					iter = _tmp3_;
				}
				_tmp1_ = FALSE;
				_tmp4_ = iter;
				if (!(_tmp4_ != NULL)) {
					break;
				}
				_tmp5_ = iter;
				cb (_tmp5_, cb_target);
			}
		}
	}
	(cb_target_destroy_notify == NULL) ? NULL : (cb_target_destroy_notify (cb_target), NULL);
	cb = NULL;
	cb_target = NULL;
	cb_target_destroy_notify = NULL;
}

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

static Block28Data*
block28_data_ref (Block28Data* _data28_)
{
	g_atomic_int_inc (&_data28_->_ref_count_);
	return _data28_;
}

static void
block28_data_unref (void * _userdata_)
{
	Block28Data* _data28_;
	_data28_ = (Block28Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data28_->_ref_count_)) {
		_g_object_unref0 (_data28_->v);
		(_data28_->handler_target_destroy_notify == NULL) ? NULL : (_data28_->handler_target_destroy_notify (_data28_->handler_target), NULL);
		_data28_->handler = NULL;
		_data28_->handler_target = NULL;
		_data28_->handler_target_destroy_notify = NULL;
		g_slice_free (Block28Data, _data28_);
	}
}

static void
__lambda30_ (Block28Data* _data28_,
             xmlNode* node)
{
	_data28_->handler (_data28_->v, node, _data28_->handler_target);
}

static void
___lambda30__tootle_widgets_markup_view_node_fn (xmlNode* node,
                                                 gpointer self)
{
	__lambda30_ (self, node);
}

static void
tootle_widgets_markup_view_traverse_and_handle (TootleWidgetsMarkupView* v,
                                                xmlNode* root,
                                                TootleWidgetsMarkupViewNodeHandlerFn handler,
                                                gpointer handler_target,
                                                GDestroyNotify handler_target_destroy_notify)
{
	Block28Data* _data28_;
	TootleWidgetsMarkupView* _tmp0_;
	g_return_if_fail (v != NULL);
	_data28_ = g_slice_new0 (Block28Data);
	_data28_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (v);
	_g_object_unref0 (_data28_->v);
	_data28_->v = _tmp0_;
	(_data28_->handler_target_destroy_notify == NULL) ? NULL : (_data28_->handler_target_destroy_notify (_data28_->handler_target), NULL);
	_data28_->handler = NULL;
	_data28_->handler_target = NULL;
	_data28_->handler_target_destroy_notify = NULL;
	_data28_->handler = handler;
	_data28_->handler_target = handler_target;
	_data28_->handler_target_destroy_notify = handler_target_destroy_notify;
	tootle_widgets_markup_view_traverse (root, ___lambda30__tootle_widgets_markup_view_node_fn, block28_data_ref (_data28_), block28_data_unref);
	block28_data_unref (_data28_);
	_data28_ = NULL;
}

static void
tootle_widgets_markup_view_commit_chunk (TootleWidgetsMarkupView* self)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->current_chunk;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		_tmp2_ = self->priv->current_chunk;
		_tmp0_ = g_strcmp0 (_tmp2_, "") != 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		TootleWidgetsRichLabel* label = NULL;
		const gchar* _tmp3_;
		TootleWidgetsRichLabel* _tmp4_ = NULL;
		TootleWidgetsRichLabel* _tmp5_;
		_tmp3_ = self->priv->current_chunk;
		_tmp4_ = tootle_widgets_rich_label_new (_tmp3_);
		gtk_widget_set_visible ((GtkWidget*) _tmp4_, TRUE);
		tootle_widgets_rich_label_set_markup (_tmp4_, TOOTLE_MARKUP_POLICY_TRUST);
		gtk_label_set_selectable ((GtkLabel*) _tmp4_, self->priv->_selectable);
		g_object_ref_sink (_tmp4_);
		label = _tmp4_;
		_tmp5_ = label;
		gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp5_, TRUE, TRUE, (guint) 0);
		_g_object_unref0 (label);
	}
	_g_free0 (self->priv->current_chunk);
	self->priv->current_chunk = NULL;
}

static void
tootle_widgets_markup_view_write_chunk (TootleWidgetsMarkupView* self,
                                        const gchar* chunk)
{
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	if (chunk == NULL) {
		return;
	}
	_tmp0_ = self->priv->current_chunk;
	if (_tmp0_ == NULL) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup (chunk);
		_g_free0 (self->priv->current_chunk);
		self->priv->current_chunk = _tmp1_;
	} else {
		const gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = self->priv->current_chunk;
		_tmp3_ = g_strconcat (_tmp2_, chunk, NULL);
		_g_free0 (self->priv->current_chunk);
		self->priv->current_chunk = _tmp3_;
	}
}

static void
_tootle_widgets_markup_view_default_handler_tootle_widgets_markup_view_node_handler_fn (TootleWidgetsMarkupView* view,
                                                                                        xmlNode* node,
                                                                                        gpointer self)
{
	tootle_widgets_markup_view_default_handler (view, node);
}

static Block29Data*
block29_data_ref (Block29Data* _data29_)
{
	g_atomic_int_inc (&_data29_->_ref_count_);
	return _data29_;
}

static void
block29_data_unref (void * _userdata_)
{
	Block29Data* _data29_;
	_data29_ = (Block29Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data29_->_ref_count_)) {
		_g_free0 (_data29_->text);
		g_slice_free (Block29Data, _data29_);
	}
}

static void
___lambda31_ (Block29Data* _data29_,
              xmlNode* node)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	_tmp0_ = node->name;
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("text")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp4_;
				const gchar* _tmp5_;
				gchar* _tmp6_;
				_tmp4_ = _data29_->text;
				_tmp5_ = node->content;
				_tmp6_ = g_strconcat (_tmp4_, _tmp5_, NULL);
				_g_free0 (_data29_->text);
				_data29_->text = _tmp6_;
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				break;
			}
		}
	}
}

static void
____lambda31__tootle_widgets_markup_view_node_fn (xmlNode* node,
                                                  gpointer self)
{
	___lambda31_ (self, node);
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

void
tootle_widgets_markup_view_default_handler (TootleWidgetsMarkupView* v,
                                            xmlNode* root)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	static GQuark _tmp2_label6 = 0;
	static GQuark _tmp2_label7 = 0;
	static GQuark _tmp2_label8 = 0;
	static GQuark _tmp2_label9 = 0;
	static GQuark _tmp2_label10 = 0;
	static GQuark _tmp2_label11 = 0;
	static GQuark _tmp2_label12 = 0;
	static GQuark _tmp2_label13 = 0;
	static GQuark _tmp2_label14 = 0;
	static GQuark _tmp2_label15 = 0;
	static GQuark _tmp2_label16 = 0;
	static GQuark _tmp2_label17 = 0;
	static GQuark _tmp2_label18 = 0;
	static GQuark _tmp2_label19 = 0;
	g_return_if_fail (v != NULL);
	_tmp0_ = root->name;
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	if ((((((_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("html")))) || (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("span"))))) || (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("markup"))))) || (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("pre"))))) || (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("ul"))))) || (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("ol"))))) {
		switch (0) {
			default:
			{
				tootle_widgets_markup_view_traverse_and_handle (v, root, _tootle_widgets_markup_view_default_handler_tootle_widgets_markup_view_node_handler_fn, NULL, NULL);
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label6) ? _tmp2_label6 : (_tmp2_label6 = g_quark_from_static_string ("body")))) {
		switch (0) {
			default:
			{
				tootle_widgets_markup_view_traverse_and_handle (v, root, _tootle_widgets_markup_view_default_handler_tootle_widgets_markup_view_node_handler_fn, NULL, NULL);
				tootle_widgets_markup_view_commit_chunk (v);
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label7) ? _tmp2_label7 : (_tmp2_label7 = g_quark_from_static_string ("p")))) {
		switch (0) {
			default:
			{
				gboolean _tmp4_ = FALSE;
				const gchar* _tmp5_;
				_tmp5_ = v->priv->current_chunk;
				if (g_strcmp0 (_tmp5_, "") != 0) {
					const gchar* _tmp6_;
					_tmp6_ = v->priv->current_chunk;
					_tmp4_ = _tmp6_ != NULL;
				} else {
					_tmp4_ = FALSE;
				}
				if (_tmp4_) {
					tootle_widgets_markup_view_write_chunk (v, "\n\n");
				}
				tootle_widgets_markup_view_traverse_and_handle (v, root, _tootle_widgets_markup_view_default_handler_tootle_widgets_markup_view_node_handler_fn, NULL, NULL);
				break;
			}
		}
	} else if ((_tmp3_ == ((0 != _tmp2_label8) ? _tmp2_label8 : (_tmp2_label8 = g_quark_from_static_string ("code")))) || (_tmp3_ == ((0 != _tmp2_label9) ? _tmp2_label9 : (_tmp2_label9 = g_quark_from_static_string ("blockquote"))))) {
		switch (0) {
			default:
			{
				Block29Data* _data29_;
				gchar* _tmp7_;
				TootleWidgetsRichLabel* label = NULL;
				const gchar* _tmp8_;
				TootleWidgetsRichLabel* _tmp9_ = NULL;
				TootleWidgetsRichLabel* _tmp10_;
				GtkStyleContext* _tmp11_;
				TootleWidgetsRichLabel* _tmp12_;
				_data29_ = g_slice_new0 (Block29Data);
				_data29_->_ref_count_ = 1;
				tootle_widgets_markup_view_commit_chunk (v);
				_tmp7_ = g_strdup ("");
				_data29_->text = _tmp7_;
				tootle_widgets_markup_view_traverse (root, ____lambda31__tootle_widgets_markup_view_node_fn, block29_data_ref (_data29_), block29_data_unref);
				_tmp8_ = _data29_->text;
				_tmp9_ = tootle_widgets_rich_label_new (_tmp8_);
				gtk_widget_set_visible ((GtkWidget*) _tmp9_, TRUE);
				tootle_widgets_rich_label_set_markup (_tmp9_, TOOTLE_MARKUP_POLICY_DISALLOW);
				g_object_ref_sink (_tmp9_);
				label = _tmp9_;
				_tmp10_ = label;
				_tmp11_ = gtk_widget_get_style_context ((GtkWidget*) _tmp10_);
				gtk_style_context_add_class (_tmp11_, "ttl-code");
				_tmp12_ = label;
				gtk_box_pack_start ((GtkBox*) v, (GtkWidget*) _tmp12_, TRUE, TRUE, (guint) 0);
				_g_object_unref0 (label);
				block29_data_unref (_data29_);
				_data29_ = NULL;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label10) ? _tmp2_label10 : (_tmp2_label10 = g_quark_from_static_string ("a")))) {
		switch (0) {
			default:
			{
				gchar* href = NULL;
				gchar* _tmp13_;
				const gchar* _tmp14_;
				_tmp13_ = (gchar*) xmlGetProp (root, (xmlChar*) "href");
				href = _tmp13_;
				_tmp14_ = href;
				if (_tmp14_ != NULL) {
					const gchar* _tmp15_;
					gchar* _tmp16_;
					gchar* _tmp17_;
					gchar* _tmp18_;
					gchar* _tmp19_;
					gchar* _tmp20_;
					gchar* _tmp21_;
					_tmp15_ = href;
					_tmp16_ = g_markup_escape_text (_tmp15_, (gssize) -1);
					_tmp17_ = _tmp16_;
					_tmp18_ = g_strconcat ("<a href='", _tmp17_, NULL);
					_tmp19_ = _tmp18_;
					_tmp20_ = g_strconcat (_tmp19_, "'>", NULL);
					_tmp21_ = _tmp20_;
					tootle_widgets_markup_view_write_chunk (v, _tmp21_);
					_g_free0 (_tmp21_);
					_g_free0 (_tmp19_);
					_g_free0 (_tmp17_);
					tootle_widgets_markup_view_traverse_and_handle (v, root, _tootle_widgets_markup_view_default_handler_tootle_widgets_markup_view_node_handler_fn, NULL, NULL);
					tootle_widgets_markup_view_write_chunk (v, "</a>");
				}
				_g_free0 (href);
				break;
			}
		}
	} else if ((((((_tmp3_ == ((0 != _tmp2_label11) ? _tmp2_label11 : (_tmp2_label11 = g_quark_from_static_string ("b")))) || (_tmp3_ == ((0 != _tmp2_label12) ? _tmp2_label12 : (_tmp2_label12 = g_quark_from_static_string ("i"))))) || (_tmp3_ == ((0 != _tmp2_label13) ? _tmp2_label13 : (_tmp2_label13 = g_quark_from_static_string ("u"))))) || (_tmp3_ == ((0 != _tmp2_label14) ? _tmp2_label14 : (_tmp2_label14 = g_quark_from_static_string ("s"))))) || (_tmp3_ == ((0 != _tmp2_label15) ? _tmp2_label15 : (_tmp2_label15 = g_quark_from_static_string ("sup"))))) || (_tmp3_ == ((0 != _tmp2_label16) ? _tmp2_label16 : (_tmp2_label16 = g_quark_from_static_string ("sub"))))) {
		switch (0) {
			default:
			{
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				gchar* _tmp24_;
				gchar* _tmp25_;
				const gchar* _tmp26_;
				const gchar* _tmp27_;
				gchar* _tmp28_;
				gchar* _tmp29_;
				_tmp22_ = root->name;
				_tmp23_ = string_to_string (_tmp22_);
				_tmp24_ = g_strconcat ("<", _tmp23_, ">", NULL);
				_tmp25_ = _tmp24_;
				tootle_widgets_markup_view_write_chunk (v, _tmp25_);
				_g_free0 (_tmp25_);
				tootle_widgets_markup_view_traverse_and_handle (v, root, _tootle_widgets_markup_view_default_handler_tootle_widgets_markup_view_node_handler_fn, NULL, NULL);
				_tmp26_ = root->name;
				_tmp27_ = string_to_string (_tmp26_);
				_tmp28_ = g_strconcat ("</", _tmp27_, ">", NULL);
				_tmp29_ = _tmp28_;
				tootle_widgets_markup_view_write_chunk (v, _tmp29_);
				_g_free0 (_tmp29_);
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label17) ? _tmp2_label17 : (_tmp2_label17 = g_quark_from_static_string ("li")))) {
		switch (0) {
			default:
			{
				tootle_widgets_markup_view_write_chunk (v, "\n• ");
				tootle_widgets_markup_view_traverse_and_handle (v, root, _tootle_widgets_markup_view_default_handler_tootle_widgets_markup_view_node_handler_fn, NULL, NULL);
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label18) ? _tmp2_label18 : (_tmp2_label18 = g_quark_from_static_string ("br")))) {
		switch (0) {
			default:
			{
				tootle_widgets_markup_view_write_chunk (v, "\n");
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label19) ? _tmp2_label19 : (_tmp2_label19 = g_quark_from_static_string ("text")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp30_;
				_tmp30_ = root->content;
				if (_tmp30_ != NULL) {
					const gchar* _tmp31_;
					gchar* _tmp32_;
					gchar* _tmp33_;
					_tmp31_ = root->content;
					_tmp32_ = g_markup_escape_text (_tmp31_, (gssize) -1);
					_tmp33_ = _tmp32_;
					tootle_widgets_markup_view_write_chunk (v, _tmp33_);
					_g_free0 (_tmp33_);
				}
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				const gchar* _tmp34_;
				const gchar* _tmp35_;
				gchar* _tmp36_;
				gchar* _tmp37_;
				_tmp34_ = root->name;
				_tmp35_ = string_to_string (_tmp34_);
				_tmp36_ = g_strconcat ("Unknown HTML tag: \"", _tmp35_, "\"", NULL);
				_tmp37_ = _tmp36_;
				g_warning ("MarkupView.vala:168: %s", _tmp37_);
				_g_free0 (_tmp37_);
				tootle_widgets_markup_view_traverse_and_handle (v, root, _tootle_widgets_markup_view_default_handler_tootle_widgets_markup_view_node_handler_fn, NULL, NULL);
				break;
			}
		}
	}
}

TootleWidgetsMarkupView*
tootle_widgets_markup_view_construct (GType object_type)
{
	TootleWidgetsMarkupView * self = NULL;
	self = (TootleWidgetsMarkupView*) g_object_new (object_type, NULL);
	return self;
}

TootleWidgetsMarkupView*
tootle_widgets_markup_view_new (void)
{
	return tootle_widgets_markup_view_construct (TOOTLE_WIDGETS_TYPE_MARKUP_VIEW);
}

const gchar*
tootle_widgets_markup_view_get_content (TootleWidgetsMarkupView* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_content;
	result = _tmp0_;
	return result;
}

void
tootle_widgets_markup_view_set_content (TootleWidgetsMarkupView* self,
                                        const gchar* value)
{
	gchar* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_content);
	self->priv->_content = _tmp0_;
	_tmp1_ = self->priv->_content;
	tootle_widgets_markup_view_update_content (self, _tmp1_);
	g_object_notify_by_pspec ((GObject *) self, tootle_widgets_markup_view_properties[TOOTLE_WIDGETS_MARKUP_VIEW_CONTENT_PROPERTY]);
}

gboolean
tootle_widgets_markup_view_get_selectable (TootleWidgetsMarkupView* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_selectable;
	return result;
}

static void
_tootle_widgets_markup_view_selectable___lambda32_ (TootleWidgetsMarkupView* self,
                                                    GtkWidget* w)
{
	GtkLabel* label = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	g_return_if_fail (w != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (w, gtk_label_get_type ()) ? ((GtkLabel*) w) : NULL);
	label = _tmp0_;
	_tmp1_ = label;
	if (_tmp1_ != NULL) {
		GtkLabel* _tmp2_;
		_tmp2_ = label;
		gtk_label_set_selectable (_tmp2_, self->priv->_selectable);
	}
	_g_object_unref0 (label);
}

static void
__tootle_widgets_markup_view_selectable___lambda32__gfunc (gconstpointer data,
                                                           gpointer self)
{
	_tootle_widgets_markup_view_selectable___lambda32_ ((TootleWidgetsMarkupView*) self, (GtkWidget*) data);
}

void
tootle_widgets_markup_view_set_selectable (TootleWidgetsMarkupView* self,
                                           gboolean value)
{
	GList* _tmp0_;
	GList* _tmp1_;
	g_return_if_fail (self != NULL);
	self->priv->_selectable = value;
	_tmp0_ = gtk_container_get_children ((GtkContainer*) self);
	_tmp1_ = _tmp0_;
	g_list_foreach (_tmp1_, __tootle_widgets_markup_view_selectable___lambda32__gfunc, self);
	(_tmp1_ == NULL) ? NULL : (_tmp1_ = (g_list_free (_tmp1_), NULL));
	g_object_notify_by_pspec ((GObject *) self, tootle_widgets_markup_view_properties[TOOTLE_WIDGETS_MARKUP_VIEW_SELECTABLE_PROPERTY]);
}

static GObject *
tootle_widgets_markup_view_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TootleWidgetsMarkupView * self;
	parent_class = G_OBJECT_CLASS (tootle_widgets_markup_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_WIDGETS_TYPE_MARKUP_VIEW, TootleWidgetsMarkupView);
	gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_VERTICAL);
	gtk_box_set_spacing ((GtkBox*) self, 12);
	return obj;
}

static void
tootle_widgets_markup_view_class_init (TootleWidgetsMarkupViewClass * klass,
                                       gpointer klass_data)
{
	tootle_widgets_markup_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleWidgetsMarkupView_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tootle_widgets_markup_view_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tootle_widgets_markup_view_set_property;
	G_OBJECT_CLASS (klass)->constructor = tootle_widgets_markup_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = tootle_widgets_markup_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_WIDGETS_MARKUP_VIEW_CONTENT_PROPERTY, tootle_widgets_markup_view_properties[TOOTLE_WIDGETS_MARKUP_VIEW_CONTENT_PROPERTY] = g_param_spec_string ("content", "content", "content", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_WIDGETS_MARKUP_VIEW_SELECTABLE_PROPERTY, tootle_widgets_markup_view_properties[TOOTLE_WIDGETS_MARKUP_VIEW_SELECTABLE_PROPERTY] = g_param_spec_boolean ("selectable", "selectable", "selectable", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
tootle_widgets_markup_view_instance_init (TootleWidgetsMarkupView * self,
                                          gpointer klass)
{
	gchar* _tmp0_;
	self->priv = tootle_widgets_markup_view_get_instance_private (self);
	self->priv->current_chunk = NULL;
	_tmp0_ = g_strdup ("");
	self->priv->_content = _tmp0_;
	self->priv->_selectable = FALSE;
}

static void
tootle_widgets_markup_view_finalize (GObject * obj)
{
	TootleWidgetsMarkupView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_WIDGETS_TYPE_MARKUP_VIEW, TootleWidgetsMarkupView);
	_g_free0 (self->priv->current_chunk);
	_g_free0 (self->priv->_content);
	G_OBJECT_CLASS (tootle_widgets_markup_view_parent_class)->finalize (obj);
}

static GType
tootle_widgets_markup_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleWidgetsMarkupViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_widgets_markup_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleWidgetsMarkupView), 0, (GInstanceInitFunc) tootle_widgets_markup_view_instance_init, NULL };
	GType tootle_widgets_markup_view_type_id;
	tootle_widgets_markup_view_type_id = g_type_register_static (gtk_box_get_type (), "TootleWidgetsMarkupView", &g_define_type_info, 0);
	TootleWidgetsMarkupView_private_offset = g_type_add_instance_private (tootle_widgets_markup_view_type_id, sizeof (TootleWidgetsMarkupViewPrivate));
	return tootle_widgets_markup_view_type_id;
}

GType
tootle_widgets_markup_view_get_type (void)
{
	static volatile gsize tootle_widgets_markup_view_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_widgets_markup_view_type_id__volatile)) {
		GType tootle_widgets_markup_view_type_id;
		tootle_widgets_markup_view_type_id = tootle_widgets_markup_view_get_type_once ();
		g_once_init_leave (&tootle_widgets_markup_view_type_id__volatile, tootle_widgets_markup_view_type_id);
	}
	return tootle_widgets_markup_view_type_id__volatile;
}

static void
_vala_tootle_widgets_markup_view_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	TootleWidgetsMarkupView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_WIDGETS_TYPE_MARKUP_VIEW, TootleWidgetsMarkupView);
	switch (property_id) {
		case TOOTLE_WIDGETS_MARKUP_VIEW_CONTENT_PROPERTY:
		g_value_set_string (value, tootle_widgets_markup_view_get_content (self));
		break;
		case TOOTLE_WIDGETS_MARKUP_VIEW_SELECTABLE_PROPERTY:
		g_value_set_boolean (value, tootle_widgets_markup_view_get_selectable (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tootle_widgets_markup_view_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	TootleWidgetsMarkupView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_WIDGETS_TYPE_MARKUP_VIEW, TootleWidgetsMarkupView);
	switch (property_id) {
		case TOOTLE_WIDGETS_MARKUP_VIEW_CONTENT_PROPERTY:
		tootle_widgets_markup_view_set_content (self, g_value_get_string (value));
		break;
		case TOOTLE_WIDGETS_MARKUP_VIEW_SELECTABLE_PROPERTY:
		tootle_widgets_markup_view_set_selectable (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

