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

/*
* Copyright (c) 2018-2026 (https://github.com/phase1geo/Minder)
*
* 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., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Trevor Williams <phase1geo@gmail.com>
*/

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <granite-7.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gio/gio.h>
#include <gobject/gvaluecollector.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 TYPE_URL_EDITOR (url_editor_get_type ())
#define URL_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_URL_EDITOR, UrlEditor))
#define URL_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_URL_EDITOR, UrlEditorClass))
#define IS_URL_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_URL_EDITOR))
#define IS_URL_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_URL_EDITOR))
#define URL_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_URL_EDITOR, UrlEditorClass))

typedef struct _UrlEditor UrlEditor;
typedef struct _UrlEditorClass UrlEditorClass;
typedef struct _UrlEditorPrivate UrlEditorPrivate;

#define TYPE_MIND_MAP (mind_map_get_type ())
#define MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MIND_MAP, MindMap))
#define MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MIND_MAP, MindMapClass))
#define IS_MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MIND_MAP))
#define IS_MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MIND_MAP))
#define MIND_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MIND_MAP, MindMapClass))

typedef struct _MindMap MindMap;
typedef struct _MindMapClass MindMapClass;
#define _mind_map_unref0(var) ((var == NULL) ? NULL : (var = (mind_map_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_DRAW_AREA (draw_area_get_type ())
#define DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DRAW_AREA, DrawArea))
#define DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DRAW_AREA, DrawAreaClass))
#define IS_DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DRAW_AREA))
#define IS_DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DRAW_AREA))
#define DRAW_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DRAW_AREA, DrawAreaClass))

typedef struct _DrawArea DrawArea;
typedef struct _DrawAreaClass DrawAreaClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_CANVAS_TEXT (canvas_text_get_type ())
#define CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CANVAS_TEXT, CanvasText))
#define CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CANVAS_TEXT, CanvasTextClass))
#define IS_CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CANVAS_TEXT))
#define IS_CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CANVAS_TEXT))
#define CANVAS_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CANVAS_TEXT, CanvasTextClass))

typedef struct _CanvasText CanvasText;
typedef struct _CanvasTextClass CanvasTextClass;

#define TYPE_NODE (node_get_type ())
#define NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE, Node))
#define NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE, NodeClass))
#define IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE))
#define IS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE))
#define NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE, NodeClass))

typedef struct _Node Node;
typedef struct _NodeClass NodeClass;

#define TYPE_CONNECTION (connection_get_type ())
#define CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONNECTION, Connection))
#define CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONNECTION, ConnectionClass))
#define IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONNECTION))
#define IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONNECTION))
#define CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONNECTION, ConnectionClass))

typedef struct _Connection Connection;
typedef struct _ConnectionClass ConnectionClass;

#define TYPE_CALLOUT (callout_get_type ())
#define CALLOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CALLOUT, Callout))
#define CALLOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CALLOUT, CalloutClass))
#define IS_CALLOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CALLOUT))
#define IS_CALLOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CALLOUT))
#define CALLOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CALLOUT, CalloutClass))

typedef struct _Callout Callout;
typedef struct _CalloutClass CalloutClass;
typedef enum  {
	NODE_MODE_NONE = 0,
	NODE_MODE_CURRENT,
	NODE_MODE_SELECTED,
	NODE_MODE_EDITABLE,
	NODE_MODE_ATTACHABLE,
	NODE_MODE_DROPPABLE,
	NODE_MODE_HIGHLIGHTED
} NodeMode;

#define TYPE_NODE_MODE (node_mode_get_type ())

#define TYPE_MAP_MODEL (map_model_get_type ())
#define MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAP_MODEL, MapModel))
#define MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAP_MODEL, MapModelClass))
#define IS_MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAP_MODEL))
#define IS_MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAP_MODEL))
#define MAP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAP_MODEL, MapModelClass))

typedef struct _MapModel MapModel;
typedef struct _MapModelClass MapModelClass;
typedef enum  {
	CONN_MODE_NONE = 0,
	CONN_MODE_LINKING,
	CONN_MODE_CONNECTING,
	CONN_MODE_SELECTED,
	CONN_MODE_ADJUSTING,
	CONN_MODE_EDITABLE,
	CONN_MODE_DROPPABLE
} ConnMode;

#define TYPE_CONN_MODE (conn_mode_get_type ())
typedef enum  {
	CALLOUT_MODE_NONE = 0,
	CALLOUT_MODE_SELECTED,
	CALLOUT_MODE_EDITABLE,
	CALLOUT_MODE_HIDING,
	CALLOUT_MODE_HIDDEN
} CalloutMode;

#define TYPE_CALLOUT_MODE (callout_mode_get_type ())
typedef enum  {
	FORMAT_TAG_BOLD = 0,
	FORMAT_TAG_ITALICS,
	FORMAT_TAG_UNDERLINE,
	FORMAT_TAG_STRIKETHRU,
	FORMAT_TAG_CODE,
	FORMAT_TAG_SUB,
	FORMAT_TAG_SUPER,
	FORMAT_TAG_HEADER,
	FORMAT_TAG_COLOR,
	FORMAT_TAG_HILITE,
	FORMAT_TAG_URL,
	FORMAT_TAG_SYNTAX,
	FORMAT_TAG_TAG,
	FORMAT_TAG_MATCH,
	FORMAT_TAG_SELECT,
	FORMAT_TAG_LENGTH
} FormatTag;

#define TYPE_FORMAT_TAG (format_tag_get_type ())

#define TYPE_UNDO_BUFFER (undo_buffer_get_type ())
#define UNDO_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDO_BUFFER, UndoBuffer))
#define UNDO_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDO_BUFFER, UndoBufferClass))
#define IS_UNDO_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDO_BUFFER))
#define IS_UNDO_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDO_BUFFER))
#define UNDO_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDO_BUFFER, UndoBufferClass))

typedef struct _UndoBuffer UndoBuffer;
typedef struct _UndoBufferClass UndoBufferClass;

#define TYPE_UNDO_TEXT_BUFFER (undo_text_buffer_get_type ())
#define UNDO_TEXT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDO_TEXT_BUFFER, UndoTextBuffer))
#define UNDO_TEXT_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDO_TEXT_BUFFER, UndoTextBufferClass))
#define IS_UNDO_TEXT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDO_TEXT_BUFFER))
#define IS_UNDO_TEXT_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDO_TEXT_BUFFER))
#define UNDO_TEXT_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDO_TEXT_BUFFER, UndoTextBufferClass))

typedef struct _UndoTextBuffer UndoTextBuffer;
typedef struct _UndoTextBufferClass UndoTextBufferClass;
typedef struct _Block82Data Block82Data;
#define _url_editor_unref0(var) ((var == NULL) ? NULL : (var = (url_editor_unref (var), NULL)))

#define TYPE_UNDO_TAG_INFO (undo_tag_info_get_type ())
#define UNDO_TAG_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDO_TAG_INFO, UndoTagInfo))
#define UNDO_TAG_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDO_TAG_INFO, UndoTagInfoClass))
#define IS_UNDO_TAG_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDO_TAG_INFO))
#define IS_UNDO_TAG_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDO_TAG_INFO))
#define UNDO_TAG_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDO_TAG_INFO, UndoTagInfoClass))

typedef struct _UndoTagInfo UndoTagInfo;
typedef struct _UndoTagInfoClass UndoTagInfoClass;

#define TYPE_FORMATTED_TEXT (formatted_text_get_type ())
#define FORMATTED_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FORMATTED_TEXT, FormattedText))
#define FORMATTED_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FORMATTED_TEXT, FormattedTextClass))
#define IS_FORMATTED_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FORMATTED_TEXT))
#define IS_FORMATTED_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FORMATTED_TEXT))
#define FORMATTED_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FORMATTED_TEXT, FormattedTextClass))

typedef struct _FormattedText FormattedText;
typedef struct _FormattedTextClass FormattedTextClass;
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))
typedef struct _ParamSpecUrlEditor ParamSpecUrlEditor;

struct _UrlEditor {
	GTypeInstance parent_instance;
	volatile int ref_count;
	UrlEditorPrivate * priv;
};

struct _UrlEditorClass {
	GTypeClass parent_class;
	void (*finalize) (UrlEditor *self);
};

struct _UrlEditorPrivate {
	MindMap* _map;
	GtkPopover* _popover;
	gboolean _add;
	GtkEntry* _entry;
	GtkButton* _apply;
};

struct _Block82Data {
	int _ref_count_;
	UrlEditor* self;
	GdkClipboard* clipboard;
};

struct _ParamSpecUrlEditor {
	GParamSpec parent_instance;
};

static gint UrlEditor_private_offset;
static gpointer url_editor_parent_class = NULL;

VALA_EXTERN gpointer url_editor_ref (gpointer instance);
VALA_EXTERN void url_editor_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_url_editor (const gchar* name,
                                   const gchar* nick,
                                   const gchar* blurb,
                                   GType object_type,
                                   GParamFlags flags);
VALA_EXTERN void value_set_url_editor (GValue* value,
                           gpointer v_object);
VALA_EXTERN void value_take_url_editor (GValue* value,
                            gpointer v_object);
VALA_EXTERN gpointer value_get_url_editor (const GValue* value);
VALA_EXTERN GType url_editor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UrlEditor, url_editor_unref)
VALA_EXTERN gpointer mind_map_ref (gpointer instance);
VALA_EXTERN void mind_map_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_mind_map (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags);
VALA_EXTERN void value_set_mind_map (GValue* value,
                         gpointer v_object);
VALA_EXTERN void value_take_mind_map (GValue* value,
                          gpointer v_object);
VALA_EXTERN gpointer value_get_mind_map (const GValue* value);
VALA_EXTERN GType mind_map_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MindMap, mind_map_unref)
VALA_EXTERN GType draw_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DrawArea, g_object_unref)
VALA_EXTERN UrlEditor* url_editor_new (DrawArea* da);
VALA_EXTERN UrlEditor* url_editor_construct (GType object_type,
                                 DrawArea* da);
VALA_EXTERN MindMap* draw_area_get_map (DrawArea* self);
static void __lambda123_ (UrlEditor* self);
static void ___lambda123__gtk_entry_activate (GtkEntry* _sender,
                                       gpointer self);
static void url_editor_check_entry (UrlEditor* self);
static void _url_editor_check_entry_gtk_editable_changed (GtkEditable* _sender,
                                                   gpointer self);
static void __lambda124_ (UrlEditor* self);
static void url_editor_set_url (UrlEditor* self);
static void ___lambda124__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda125_ (UrlEditor* self);
VALA_EXTERN GType canvas_text_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CanvasText, g_object_unref)
VALA_EXTERN CanvasText* mind_map_get_current_text (MindMap* self);
VALA_EXTERN void canvas_text_clear_selection (CanvasText* self,
                                  const gchar* msg);
static void ___lambda125__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN gboolean utils_is_url (const gchar* str);
VALA_EXTERN GType node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Node, g_object_unref)
VALA_EXTERN Node* mind_map_get_current_node (MindMap* self);
VALA_EXTERN GType connection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Connection, g_object_unref)
VALA_EXTERN Connection* mind_map_get_current_connection (MindMap* self);
VALA_EXTERN GType callout_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Callout, g_object_unref)
VALA_EXTERN Callout* mind_map_get_current_callout (MindMap* self);
VALA_EXTERN GType node_mode_get_type (void) G_GNUC_CONST ;
VALA_EXTERN NodeMode node_get_mode (Node* self);
VALA_EXTERN gpointer map_model_ref (gpointer instance);
VALA_EXTERN void map_model_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_map_model (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags);
VALA_EXTERN void value_set_map_model (GValue* value,
                          gpointer v_object);
VALA_EXTERN void value_take_map_model (GValue* value,
                           gpointer v_object);
VALA_EXTERN gpointer value_get_map_model (const GValue* value);
VALA_EXTERN GType map_model_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MapModel, map_model_unref)
VALA_EXTERN MapModel* mind_map_get_model (MindMap* self);
VALA_EXTERN void map_model_set_node_mode (MapModel* self,
                              Node* node,
                              NodeMode mode,
                              gboolean undoable);
VALA_EXTERN GType conn_mode_get_type (void) G_GNUC_CONST ;
VALA_EXTERN ConnMode connection_get_mode (Connection* self);
VALA_EXTERN void map_model_set_connection_mode (MapModel* self,
                                    Connection* conn,
                                    ConnMode mode,
                                    gboolean undoable);
VALA_EXTERN GType callout_mode_get_type (void) G_GNUC_CONST ;
VALA_EXTERN CalloutMode callout_get_mode (Callout* self);
VALA_EXTERN void map_model_set_callout_mode (MapModel* self,
                                 Callout* callout,
                                 CalloutMode mode,
                                 gboolean undoable);
VALA_EXTERN GType format_tag_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType undo_buffer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoBuffer, g_object_unref)
VALA_EXTERN GType undo_text_buffer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoTextBuffer, g_object_unref)
VALA_EXTERN void canvas_text_remove_tag (CanvasText* self,
                             FormatTag tag,
                             UndoTextBuffer* undo_buffer);
VALA_EXTERN UndoTextBuffer* mind_map_get_undo_text (MindMap* self);
VALA_EXTERN void canvas_text_add_tag (CanvasText* self,
                          FormatTag tag,
                          const gchar* extra,
                          gboolean parsed,
                          UndoTextBuffer* undo_buffer);
VALA_EXTERN void mind_map_queue_draw (MindMap* self);
VALA_EXTERN void mind_map_auto_save (MindMap* self);
VALA_EXTERN void url_editor_add_url (UrlEditor* self);
VALA_EXTERN void canvas_text_get_cursor_info (CanvasText* self,
                                  gint* cursor,
                                  gint* start,
                                  gint* end);
VALA_EXTERN void canvas_text_get_char_pos (CanvasText* self,
                               gint pos,
                               gdouble* left,
                               gdouble* top,
                               gdouble* bottom,
                               gint* line);
static void url_editor_set_url_from_clipboard (UrlEditor* self);
VALA_EXTERN void url_editor_remove_url (UrlEditor* self);
static Block82Data* block82_data_ref (Block82Data* _data82_);
static void block82_data_unref (void * _userdata_);
static void ____lambda126_ (Block82Data* _data82_,
                     GObject* obj,
                     GAsyncResult* res);
static void _____lambda126__gasync_ready_callback (GObject* source_object,
                                            GAsyncResult* res,
                                            gpointer self);
VALA_EXTERN void url_editor_edit_url (UrlEditor* self);
VALA_EXTERN gpointer undo_tag_info_ref (gpointer instance);
VALA_EXTERN void undo_tag_info_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_undo_tag_info (const gchar* name,
                                      const gchar* nick,
                                      const gchar* blurb,
                                      GType object_type,
                                      GParamFlags flags);
VALA_EXTERN void value_set_undo_tag_info (GValue* value,
                              gpointer v_object);
VALA_EXTERN void value_take_undo_tag_info (GValue* value,
                               gpointer v_object);
VALA_EXTERN gpointer value_get_undo_tag_info (const GValue* value);
VALA_EXTERN GType undo_tag_info_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoTagInfo, undo_tag_info_unref)
VALA_EXTERN gpointer formatted_text_ref (gpointer instance);
VALA_EXTERN void formatted_text_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_formatted_text (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_formatted_text (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_formatted_text (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_formatted_text (const GValue* value);
VALA_EXTERN GType formatted_text_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FormattedText, formatted_text_unref)
VALA_EXTERN FormattedText* canvas_text_get_text (CanvasText* self);
VALA_EXTERN GArray* formatted_text_get_full_tags_in_range (FormattedText* self,
                                               FormatTag tag,
                                               gint start,
                                               gint end);
VALA_EXTERN gint undo_tag_info_get_start (UndoTagInfo* self);
VALA_EXTERN const gchar* undo_tag_info_get_extra (UndoTagInfo* self);
static void url_editor_finalize (UrlEditor * obj);
static GType url_editor_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
url_editor_get_instance_private (UrlEditor* self)
{
	return G_STRUCT_MEMBER_P (self, UrlEditor_private_offset);
}

static gpointer
_mind_map_ref0 (gpointer self)
{
	return self ? mind_map_ref (self) : NULL;
}

static void
__lambda123_ (UrlEditor* self)
{
	GtkButton* _tmp0_;
	_tmp0_ = self->priv->_apply;
	g_signal_emit_by_name (_tmp0_, "activate");
}

static void
___lambda123__gtk_entry_activate (GtkEntry* _sender,
                                  gpointer self)
{
	__lambda123_ ((UrlEditor*) self);
}

static void
_url_editor_check_entry_gtk_editable_changed (GtkEditable* _sender,
                                              gpointer self)
{
	url_editor_check_entry ((UrlEditor*) self);
}

static void
__lambda124_ (UrlEditor* self)
{
	GtkPopover* _tmp0_;
	url_editor_set_url (self);
	_tmp0_ = self->priv->_popover;
	gtk_popover_popdown (_tmp0_);
}

static void
___lambda124__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda124_ ((UrlEditor*) self);
}

static void
__lambda125_ (UrlEditor* self)
{
	CanvasText* ct = NULL;
	MindMap* _tmp0_;
	CanvasText* _tmp1_;
	CanvasText* _tmp2_;
	GtkPopover* _tmp4_;
	_tmp0_ = self->priv->_map;
	_tmp1_ = mind_map_get_current_text (_tmp0_);
	ct = _tmp1_;
	_tmp2_ = ct;
	if (_tmp2_ != NULL) {
		CanvasText* _tmp3_;
		_tmp3_ = ct;
		canvas_text_clear_selection (_tmp3_, NULL);
	}
	_tmp4_ = self->priv->_popover;
	gtk_popover_popdown (_tmp4_);
	_g_object_unref0 (ct);
}

static void
___lambda125__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda125_ ((UrlEditor*) self);
}

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

UrlEditor*
url_editor_construct (GType object_type,
                      DrawArea* da)
{
	UrlEditor* self = NULL;
	MindMap* _tmp0_;
	MindMap* _tmp1_;
	MindMap* _tmp2_;
	GtkLabel* lbl = NULL;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkEntry* _tmp7_ = NULL;
	GtkEntry* _tmp8_;
	GtkEntry* _tmp9_;
	GtkBox* ebox = NULL;
	GtkBox* _tmp10_;
	GtkEntry* _tmp11_;
	GtkButton* _tmp12_ = NULL;
	GtkButton* _tmp13_;
	GtkButton* _tmp14_;
	GtkButton* cancel = NULL;
	GtkButton* _tmp15_ = NULL;
	GtkBox* bbox = NULL;
	GtkBox* _tmp16_;
	GtkButton* _tmp17_;
	GtkBox* box = NULL;
	GtkBox* _tmp18_ = NULL;
	GtkWidget* _tmp19_;
	GtkPopover* _tmp20_ = NULL;
	GtkPopover* _tmp21_;
	g_return_val_if_fail (da != NULL, NULL);
	self = (UrlEditor*) g_type_create_instance (object_type);
	_tmp0_ = draw_area_get_map (da);
	_tmp1_ = _tmp0_;
	_tmp2_ = _mind_map_ref0 (_tmp1_);
	_mind_map_unref0 (self->priv->_map);
	self->priv->_map = _tmp2_;
	_tmp3_ = g_strconcat (_ ("URL"), ":", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = (GtkLabel*) gtk_label_new (_tmp4_);
	g_object_ref_sink (_tmp5_);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	lbl = _tmp6_;
	_tmp7_ = (GtkEntry*) gtk_entry_new ();
	gtk_editable_set_width_chars ((GtkEditable*) _tmp7_, 50);
	gtk_entry_set_input_purpose (_tmp7_, GTK_INPUT_PURPOSE_URL);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->_entry);
	self->priv->_entry = _tmp7_;
	_tmp8_ = self->priv->_entry;
	g_signal_connect (_tmp8_, "activate", (GCallback) ___lambda123__gtk_entry_activate, self);
	_tmp9_ = self->priv->_entry;
	g_signal_connect ((GtkEditable*) _tmp9_, "changed", (GCallback) _url_editor_check_entry_gtk_editable_changed, self);
	_tmp10_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	g_object_ref_sink (_tmp10_);
	ebox = _tmp10_;
	gtk_box_append (ebox, (GtkWidget*) lbl);
	_tmp11_ = self->priv->_entry;
	gtk_box_append (ebox, (GtkWidget*) _tmp11_);
	_tmp12_ = (GtkButton*) gtk_button_new_with_label (_ ("Apply"));
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_END);
	gtk_widget_set_sensitive ((GtkWidget*) _tmp12_, FALSE);
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->_apply);
	self->priv->_apply = _tmp12_;
	_tmp13_ = self->priv->_apply;
	gtk_widget_add_css_class ((GtkWidget*) _tmp13_, GRANITE_STYLE_CLASS_SUGGESTED_ACTION);
	_tmp14_ = self->priv->_apply;
	g_signal_connect (_tmp14_, "clicked", (GCallback) ___lambda124__gtk_button_clicked, self);
	_tmp15_ = (GtkButton*) gtk_button_new_with_label (_ ("Cancel"));
	gtk_widget_set_halign ((GtkWidget*) _tmp15_, GTK_ALIGN_END);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp15_, TRUE);
	g_object_ref_sink (_tmp15_);
	cancel = _tmp15_;
	g_signal_connect (cancel, "clicked", (GCallback) ___lambda125__gtk_button_clicked, self);
	_tmp16_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
	g_object_ref_sink (_tmp16_);
	bbox = _tmp16_;
	gtk_box_append (bbox, (GtkWidget*) cancel);
	_tmp17_ = self->priv->_apply;
	gtk_box_append (bbox, (GtkWidget*) _tmp17_);
	_tmp18_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp18_, 5);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp18_, 5);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp18_, 5);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp18_, 5);
	g_object_ref_sink (_tmp18_);
	box = _tmp18_;
	gtk_box_append (box, (GtkWidget*) ebox);
	gtk_box_append (box, (GtkWidget*) bbox);
	_tmp19_ = _g_object_ref0 ((GtkWidget*) box);
	_tmp20_ = (GtkPopover*) gtk_popover_new ();
	gtk_popover_set_position (_tmp20_, GTK_POS_TOP);
	gtk_popover_set_child (_tmp20_, _tmp19_);
	_g_object_unref0 (_tmp19_);
	g_object_ref_sink (_tmp20_);
	_g_object_unref0 (self->priv->_popover);
	self->priv->_popover = _tmp20_;
	_tmp21_ = self->priv->_popover;
	gtk_widget_set_parent ((GtkWidget*) _tmp21_, (GtkWidget*) da);
	_g_object_unref0 (box);
	_g_object_unref0 (bbox);
	_g_object_unref0 (cancel);
	_g_object_unref0 (ebox);
	_g_object_unref0 (lbl);
	return self;
}

UrlEditor*
url_editor_new (DrawArea* da)
{
	return url_editor_construct (TYPE_URL_EDITOR, da);
}

static void
url_editor_check_entry (UrlEditor* self)
{
	GtkButton* _tmp0_;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_apply;
	_tmp1_ = self->priv->_entry;
	_tmp2_ = gtk_editable_get_text ((GtkEditable*) _tmp1_);
	_tmp3_ = _tmp2_;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, utils_is_url (_tmp3_));
}

static void
url_editor_set_url (UrlEditor* self)
{
	Node* node = NULL;
	MindMap* _tmp0_;
	Node* _tmp1_;
	Connection* connection = NULL;
	MindMap* _tmp2_;
	Connection* _tmp3_;
	Callout* callout = NULL;
	MindMap* _tmp4_;
	Callout* _tmp5_;
	CanvasText* ct = NULL;
	MindMap* _tmp6_;
	CanvasText* _tmp7_;
	gboolean selected = FALSE;
	Node* _tmp8_;
	CanvasText* _tmp32_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_map;
	_tmp1_ = mind_map_get_current_node (_tmp0_);
	node = _tmp1_;
	_tmp2_ = self->priv->_map;
	_tmp3_ = mind_map_get_current_connection (_tmp2_);
	connection = _tmp3_;
	_tmp4_ = self->priv->_map;
	_tmp5_ = mind_map_get_current_callout (_tmp4_);
	callout = _tmp5_;
	_tmp6_ = self->priv->_map;
	_tmp7_ = mind_map_get_current_text (_tmp6_);
	ct = _tmp7_;
	selected = FALSE;
	_tmp8_ = node;
	if (_tmp8_ != NULL) {
		Node* _tmp9_;
		NodeMode _tmp10_;
		NodeMode _tmp11_;
		_tmp9_ = node;
		_tmp10_ = node_get_mode (_tmp9_);
		_tmp11_ = _tmp10_;
		selected = _tmp11_ == NODE_MODE_CURRENT;
		if (selected) {
			MindMap* _tmp12_;
			MapModel* _tmp13_;
			MapModel* _tmp14_;
			Node* _tmp15_;
			_tmp12_ = self->priv->_map;
			_tmp13_ = mind_map_get_model (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp15_ = node;
			map_model_set_node_mode (_tmp14_, _tmp15_, NODE_MODE_EDITABLE, TRUE);
		}
	} else {
		Connection* _tmp16_;
		_tmp16_ = connection;
		if (_tmp16_ != NULL) {
			Connection* _tmp17_;
			ConnMode _tmp18_;
			ConnMode _tmp19_;
			_tmp17_ = connection;
			_tmp18_ = connection_get_mode (_tmp17_);
			_tmp19_ = _tmp18_;
			selected = _tmp19_ == CONN_MODE_SELECTED;
			if (selected) {
				MindMap* _tmp20_;
				MapModel* _tmp21_;
				MapModel* _tmp22_;
				Connection* _tmp23_;
				_tmp20_ = self->priv->_map;
				_tmp21_ = mind_map_get_model (_tmp20_);
				_tmp22_ = _tmp21_;
				_tmp23_ = connection;
				map_model_set_connection_mode (_tmp22_, _tmp23_, CONN_MODE_EDITABLE, TRUE);
			}
		} else {
			Callout* _tmp24_;
			_tmp24_ = callout;
			if (_tmp24_ != NULL) {
				Callout* _tmp25_;
				CalloutMode _tmp26_;
				CalloutMode _tmp27_;
				_tmp25_ = callout;
				_tmp26_ = callout_get_mode (_tmp25_);
				_tmp27_ = _tmp26_;
				selected = _tmp27_ == CALLOUT_MODE_SELECTED;
				if (selected) {
					MindMap* _tmp28_;
					MapModel* _tmp29_;
					MapModel* _tmp30_;
					Callout* _tmp31_;
					_tmp28_ = self->priv->_map;
					_tmp29_ = mind_map_get_model (_tmp28_);
					_tmp30_ = _tmp29_;
					_tmp31_ = callout;
					map_model_set_callout_mode (_tmp30_, _tmp31_, CALLOUT_MODE_EDITABLE, TRUE);
				}
			}
		}
	}
	_tmp32_ = ct;
	if (_tmp32_ != NULL) {
		CanvasText* _tmp37_;
		GtkEntry* _tmp38_;
		const gchar* _tmp39_;
		const gchar* _tmp40_;
		MindMap* _tmp41_;
		UndoTextBuffer* _tmp42_;
		UndoTextBuffer* _tmp43_;
		CanvasText* _tmp44_;
		MindMap* _tmp55_;
		MindMap* _tmp56_;
		if (!self->priv->_add) {
			CanvasText* _tmp33_;
			MindMap* _tmp34_;
			UndoTextBuffer* _tmp35_;
			UndoTextBuffer* _tmp36_;
			_tmp33_ = ct;
			_tmp34_ = self->priv->_map;
			_tmp35_ = mind_map_get_undo_text (_tmp34_);
			_tmp36_ = _tmp35_;
			canvas_text_remove_tag (_tmp33_, FORMAT_TAG_URL, _tmp36_);
		}
		_tmp37_ = ct;
		_tmp38_ = self->priv->_entry;
		_tmp39_ = gtk_editable_get_text ((GtkEditable*) _tmp38_);
		_tmp40_ = _tmp39_;
		_tmp41_ = self->priv->_map;
		_tmp42_ = mind_map_get_undo_text (_tmp41_);
		_tmp43_ = _tmp42_;
		canvas_text_add_tag (_tmp37_, FORMAT_TAG_URL, _tmp40_, FALSE, _tmp43_);
		_tmp44_ = ct;
		canvas_text_clear_selection (_tmp44_, NULL);
		if (selected) {
			Node* _tmp45_;
			_tmp45_ = node;
			if (_tmp45_ != NULL) {
				MindMap* _tmp46_;
				MapModel* _tmp47_;
				MapModel* _tmp48_;
				Node* _tmp49_;
				_tmp46_ = self->priv->_map;
				_tmp47_ = mind_map_get_model (_tmp46_);
				_tmp48_ = _tmp47_;
				_tmp49_ = node;
				map_model_set_node_mode (_tmp48_, _tmp49_, NODE_MODE_CURRENT, TRUE);
			} else {
				Callout* _tmp50_;
				_tmp50_ = callout;
				if (_tmp50_ != NULL) {
					MindMap* _tmp51_;
					MapModel* _tmp52_;
					MapModel* _tmp53_;
					Callout* _tmp54_;
					_tmp51_ = self->priv->_map;
					_tmp52_ = mind_map_get_model (_tmp51_);
					_tmp53_ = _tmp52_;
					_tmp54_ = callout;
					map_model_set_callout_mode (_tmp53_, _tmp54_, CALLOUT_MODE_SELECTED, TRUE);
				}
			}
		}
		_tmp55_ = self->priv->_map;
		mind_map_queue_draw (_tmp55_);
		_tmp56_ = self->priv->_map;
		mind_map_auto_save (_tmp56_);
	}
	_g_object_unref0 (ct);
	_g_object_unref0 (callout);
	_g_object_unref0 (connection);
	_g_object_unref0 (node);
}

void
url_editor_add_url (UrlEditor* self)
{
	CanvasText* ct = NULL;
	MindMap* _tmp0_;
	CanvasText* _tmp1_;
	gint selstart = 0;
	gint selend = 0;
	gint cursor = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	gdouble left = 0.0;
	gdouble top = 0.0;
	gdouble bottom = 0.0;
	gint line = 0;
	gdouble _tmp5_ = 0.0;
	gdouble _tmp6_ = 0.0;
	gdouble _tmp7_ = 0.0;
	gint _tmp8_ = 0;
	gint int_left = 0;
	gint int_top = 0;
	GdkRectangle rect = {0};
	GdkRectangle _tmp9_ = {0};
	GtkPopover* _tmp10_;
	GdkRectangle _tmp11_;
	GtkPopover* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_map;
	_tmp1_ = mind_map_get_current_text (_tmp0_);
	ct = _tmp1_;
	canvas_text_get_cursor_info (ct, &_tmp2_, &_tmp3_, &_tmp4_);
	cursor = _tmp2_;
	selstart = _tmp3_;
	selend = _tmp4_;
	canvas_text_get_char_pos (ct, selstart, &_tmp5_, &_tmp6_, &_tmp7_, &_tmp8_);
	left = _tmp5_;
	top = _tmp6_;
	bottom = _tmp7_;
	line = _tmp8_;
	int_left = (gint) left;
	int_top = (gint) top;
	_tmp9_.x = int_left;
	_tmp9_.y = int_top;
	_tmp9_.width = 1;
	_tmp9_.height = 1;
	rect = _tmp9_;
	self->priv->_add = TRUE;
	url_editor_set_url_from_clipboard (self);
	_tmp10_ = self->priv->_popover;
	_tmp11_ = rect;
	g_object_set (_tmp10_, "pointing-to", &_tmp11_, NULL);
	_tmp12_ = self->priv->_popover;
	gtk_popover_popup (_tmp12_);
	_g_object_unref0 (ct);
}

void
url_editor_remove_url (UrlEditor* self)
{
	CanvasText* ct = NULL;
	MindMap* _tmp0_;
	CanvasText* _tmp1_;
	Node* node = NULL;
	MindMap* _tmp2_;
	Node* _tmp3_;
	Callout* callout = NULL;
	MindMap* _tmp4_;
	Callout* _tmp5_;
	gboolean selected = FALSE;
	Node* _tmp6_;
	CanvasText* _tmp22_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_map;
	_tmp1_ = mind_map_get_current_text (_tmp0_);
	ct = _tmp1_;
	_tmp2_ = self->priv->_map;
	_tmp3_ = mind_map_get_current_node (_tmp2_);
	node = _tmp3_;
	_tmp4_ = self->priv->_map;
	_tmp5_ = mind_map_get_current_callout (_tmp4_);
	callout = _tmp5_;
	selected = FALSE;
	_tmp6_ = node;
	if (_tmp6_ != NULL) {
		Node* _tmp7_;
		NodeMode _tmp8_;
		NodeMode _tmp9_;
		_tmp7_ = node;
		_tmp8_ = node_get_mode (_tmp7_);
		_tmp9_ = _tmp8_;
		selected = _tmp9_ == NODE_MODE_CURRENT;
		if (selected) {
			MindMap* _tmp10_;
			MapModel* _tmp11_;
			MapModel* _tmp12_;
			Node* _tmp13_;
			_tmp10_ = self->priv->_map;
			_tmp11_ = mind_map_get_model (_tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = node;
			map_model_set_node_mode (_tmp12_, _tmp13_, NODE_MODE_EDITABLE, TRUE);
		}
	} else {
		Callout* _tmp14_;
		_tmp14_ = callout;
		if (_tmp14_ != NULL) {
			Callout* _tmp15_;
			CalloutMode _tmp16_;
			CalloutMode _tmp17_;
			_tmp15_ = callout;
			_tmp16_ = callout_get_mode (_tmp15_);
			_tmp17_ = _tmp16_;
			selected = _tmp17_ == CALLOUT_MODE_SELECTED;
			if (selected) {
				MindMap* _tmp18_;
				MapModel* _tmp19_;
				MapModel* _tmp20_;
				Callout* _tmp21_;
				_tmp18_ = self->priv->_map;
				_tmp19_ = mind_map_get_model (_tmp18_);
				_tmp20_ = _tmp19_;
				_tmp21_ = callout;
				map_model_set_callout_mode (_tmp20_, _tmp21_, CALLOUT_MODE_EDITABLE, TRUE);
			}
		}
	}
	_tmp22_ = ct;
	if (_tmp22_ != NULL) {
		CanvasText* _tmp23_;
		MindMap* _tmp24_;
		UndoTextBuffer* _tmp25_;
		UndoTextBuffer* _tmp26_;
		CanvasText* _tmp27_;
		MindMap* _tmp38_;
		MindMap* _tmp39_;
		_tmp23_ = ct;
		_tmp24_ = self->priv->_map;
		_tmp25_ = mind_map_get_undo_text (_tmp24_);
		_tmp26_ = _tmp25_;
		canvas_text_remove_tag (_tmp23_, FORMAT_TAG_URL, _tmp26_);
		_tmp27_ = ct;
		canvas_text_clear_selection (_tmp27_, NULL);
		if (selected) {
			Node* _tmp28_;
			_tmp28_ = node;
			if (_tmp28_ != NULL) {
				MindMap* _tmp29_;
				MapModel* _tmp30_;
				MapModel* _tmp31_;
				Node* _tmp32_;
				_tmp29_ = self->priv->_map;
				_tmp30_ = mind_map_get_model (_tmp29_);
				_tmp31_ = _tmp30_;
				_tmp32_ = node;
				map_model_set_node_mode (_tmp31_, _tmp32_, NODE_MODE_CURRENT, TRUE);
			} else {
				Callout* _tmp33_;
				_tmp33_ = callout;
				if (_tmp33_ != NULL) {
					MindMap* _tmp34_;
					MapModel* _tmp35_;
					MapModel* _tmp36_;
					Callout* _tmp37_;
					_tmp34_ = self->priv->_map;
					_tmp35_ = mind_map_get_model (_tmp34_);
					_tmp36_ = _tmp35_;
					_tmp37_ = callout;
					map_model_set_callout_mode (_tmp36_, _tmp37_, CALLOUT_MODE_SELECTED, TRUE);
				}
			}
		}
		_tmp38_ = self->priv->_map;
		mind_map_queue_draw (_tmp38_);
		_tmp39_ = self->priv->_map;
		mind_map_auto_save (_tmp39_);
	}
	_g_object_unref0 (callout);
	_g_object_unref0 (node);
	_g_object_unref0 (ct);
}

static Block82Data*
block82_data_ref (Block82Data* _data82_)
{
	g_atomic_int_inc (&_data82_->_ref_count_);
	return _data82_;
}

static void
block82_data_unref (void * _userdata_)
{
	Block82Data* _data82_;
	_data82_ = (Block82Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data82_->_ref_count_)) {
		UrlEditor* self;
		self = _data82_->self;
		_g_object_unref0 (_data82_->clipboard);
		_url_editor_unref0 (self);
		g_slice_free (Block82Data, _data82_);
	}
}

static void
____lambda126_ (Block82Data* _data82_,
                GObject* obj,
                GAsyncResult* res)
{
	UrlEditor* self;
	gchar* text = NULL;
	GdkClipboard* _tmp0_;
	gchar* _tmp1_;
	GError* _inner_error0_ = NULL;
	self = _data82_->self;
	g_return_if_fail (res != NULL);
	_tmp0_ = _data82_->clipboard;
	_tmp1_ = gdk_clipboard_read_text_finish (_tmp0_, res, &_inner_error0_);
	text = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	if (text != NULL) {
		GtkEntry* _tmp2_;
		_tmp2_ = self->priv->_entry;
		gtk_editable_set_text ((GtkEditable*) _tmp2_, text);
		url_editor_check_entry (self);
	}
	_g_free0 (text);
}

static void
_____lambda126__gasync_ready_callback (GObject* source_object,
                                       GAsyncResult* res,
                                       gpointer self)
{
	____lambda126_ (self, source_object, res);
	block82_data_unref (self);
}

static void
url_editor_set_url_from_clipboard (UrlEditor* self)
{
	Block82Data* _data82_;
	GdkDisplay* _tmp0_;
	GdkClipboard* _tmp1_;
	GdkClipboard* _tmp2_;
	GdkClipboard* _tmp3_;
	GdkContentFormats* _tmp4_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_data82_ = g_slice_new0 (Block82Data);
	_data82_->_ref_count_ = 1;
	_data82_->self = url_editor_ref (self);
	_tmp0_ = gdk_display_get_default ();
	_tmp1_ = gdk_display_get_clipboard (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_data82_->clipboard = _tmp2_;
	_tmp3_ = _data82_->clipboard;
	_tmp4_ = gdk_clipboard_get_formats (_tmp3_);
	if (gdk_content_formats_contain_gtype (_tmp4_, G_TYPE_STRING)) {
		{
			GdkClipboard* _tmp5_;
			_tmp5_ = _data82_->clipboard;
			gdk_clipboard_read_text_async (_tmp5_, NULL, _____lambda126__gasync_ready_callback, block82_data_ref (_data82_));
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_inner_error0_);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			block82_data_unref (_data82_);
			_data82_ = NULL;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	block82_data_unref (_data82_);
	_data82_ = NULL;
}

void
url_editor_edit_url (UrlEditor* self)
{
	CanvasText* ct = NULL;
	MindMap* _tmp0_;
	CanvasText* _tmp1_;
	gint selstart = 0;
	gint selend = 0;
	gint cursor = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	gdouble left = 0.0;
	gdouble top = 0.0;
	gdouble bottom = 0.0;
	gint line = 0;
	GArray* links = NULL;
	FormattedText* _tmp5_;
	FormattedText* _tmp6_;
	GArray* _tmp7_;
	UndoTagInfo* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	gdouble _tmp11_ = 0.0;
	gdouble _tmp12_ = 0.0;
	gdouble _tmp13_ = 0.0;
	gint _tmp14_ = 0;
	gint int_left = 0;
	gint int_top = 0;
	GdkRectangle rect = {0};
	GdkRectangle _tmp15_ = {0};
	GtkEntry* _tmp16_;
	UndoTagInfo* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	GtkButton* _tmp20_;
	GtkPopover* _tmp21_;
	GdkRectangle _tmp22_;
	GtkPopover* _tmp23_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_map;
	_tmp1_ = mind_map_get_current_text (_tmp0_);
	ct = _tmp1_;
	canvas_text_get_cursor_info (ct, &_tmp2_, &_tmp3_, &_tmp4_);
	cursor = _tmp2_;
	selstart = _tmp3_;
	selend = _tmp4_;
	_tmp5_ = canvas_text_get_text (ct);
	_tmp6_ = _tmp5_;
	_tmp7_ = formatted_text_get_full_tags_in_range (_tmp6_, FORMAT_TAG_URL, cursor, cursor);
	links = _tmp7_;
	_tmp8_ = g_array_index (links, UndoTagInfo*, (guint) 0);
	_tmp9_ = undo_tag_info_get_start (_tmp8_);
	_tmp10_ = _tmp9_;
	canvas_text_get_char_pos (ct, _tmp10_, &_tmp11_, &_tmp12_, &_tmp13_, &_tmp14_);
	left = _tmp11_;
	top = _tmp12_;
	bottom = _tmp13_;
	line = _tmp14_;
	int_left = (gint) left;
	int_top = (gint) top;
	_tmp15_.x = int_left;
	_tmp15_.y = int_top;
	_tmp15_.width = 1;
	_tmp15_.height = 1;
	rect = _tmp15_;
	self->priv->_add = FALSE;
	_tmp16_ = self->priv->_entry;
	_tmp17_ = g_array_index (links, UndoTagInfo*, (guint) 0);
	_tmp18_ = undo_tag_info_get_extra (_tmp17_);
	_tmp19_ = _tmp18_;
	gtk_editable_set_text ((GtkEditable*) _tmp16_, _tmp19_);
	_tmp20_ = self->priv->_apply;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp20_, TRUE);
	_tmp21_ = self->priv->_popover;
	_tmp22_ = rect;
	g_object_set (_tmp21_, "pointing-to", &_tmp22_, NULL);
	_tmp23_ = self->priv->_popover;
	gtk_popover_popup (_tmp23_);
	_g_array_unref0 (links);
	_g_object_unref0 (ct);
}

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

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

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

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

static gchar*
value_url_editor_collect_value (GValue* value,
                                guint n_collect_values,
                                GTypeCValue* collect_values,
                                guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		UrlEditor * 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 = url_editor_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
value_url_editor_lcopy_value (const GValue* value,
                              guint n_collect_values,
                              GTypeCValue* collect_values,
                              guint collect_flags)
{
	UrlEditor ** 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 = url_editor_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
param_spec_url_editor (const gchar* name,
                       const gchar* nick,
                       const gchar* blurb,
                       GType object_type,
                       GParamFlags flags)
{
	ParamSpecUrlEditor* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_URL_EDITOR), 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_url_editor (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_URL_EDITOR), NULL);
	return value->data[0].v_pointer;
}

void
value_set_url_editor (GValue* value,
                      gpointer v_object)
{
	UrlEditor * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_URL_EDITOR));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_URL_EDITOR));
		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;
		url_editor_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		url_editor_unref (old);
	}
}

void
value_take_url_editor (GValue* value,
                       gpointer v_object)
{
	UrlEditor * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_URL_EDITOR));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_URL_EDITOR));
		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) {
		url_editor_unref (old);
	}
}

static void
url_editor_class_init (UrlEditorClass * klass,
                       gpointer klass_data)
{
	url_editor_parent_class = g_type_class_peek_parent (klass);
	((UrlEditorClass *) klass)->finalize = url_editor_finalize;
	g_type_class_adjust_private_offset (klass, &UrlEditor_private_offset);
}

static void
url_editor_instance_init (UrlEditor * self,
                          gpointer klass)
{
	self->priv = url_editor_get_instance_private (self);
	self->priv->_add = TRUE;
	self->ref_count = 1;
}

static void
url_editor_finalize (UrlEditor * obj)
{
	UrlEditor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_URL_EDITOR, UrlEditor);
	g_signal_handlers_destroy (self);
	_mind_map_unref0 (self->priv->_map);
	_g_object_unref0 (self->priv->_popover);
	_g_object_unref0 (self->priv->_entry);
	_g_object_unref0 (self->priv->_apply);
}

static GType
url_editor_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_url_editor_init, value_url_editor_free_value, value_url_editor_copy_value, value_url_editor_peek_pointer, "p", value_url_editor_collect_value, "p", value_url_editor_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (UrlEditorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) url_editor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UrlEditor), 0, (GInstanceInitFunc) url_editor_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 url_editor_type_id;
	url_editor_type_id = g_type_register_fundamental (g_type_fundamental_next (), "UrlEditor", &g_define_type_info, &g_define_type_fundamental_info, 0);
	UrlEditor_private_offset = g_type_add_instance_private (url_editor_type_id, sizeof (UrlEditorPrivate));
	return url_editor_type_id;
}

GType
url_editor_get_type (void)
{
	static volatile gsize url_editor_type_id__once = 0;
	if (g_once_init_enter (&url_editor_type_id__once)) {
		GType url_editor_type_id;
		url_editor_type_id = url_editor_get_type_once ();
		g_once_init_leave (&url_editor_type_id__once, url_editor_type_id);
	}
	return url_editor_type_id__once;
}

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

void
url_editor_unref (gpointer instance)
{
	UrlEditor * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		URL_EDITOR_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

