/* TextMenu.c generated by valac 0.56.19, the Vala compiler
 * generated from TextMenu.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 <glib.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_BASE_MENU (base_menu_get_type ())
#define BASE_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BASE_MENU, BaseMenu))
#define BASE_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BASE_MENU, BaseMenuClass))
#define IS_BASE_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BASE_MENU))
#define IS_BASE_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BASE_MENU))
#define BASE_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BASE_MENU, BaseMenuClass))

typedef struct _BaseMenu BaseMenu;
typedef struct _BaseMenuClass BaseMenuClass;
typedef struct _BaseMenuPrivate BaseMenuPrivate;

#define TYPE_TEXT_MENU (text_menu_get_type ())
#define TEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEXT_MENU, TextMenu))
#define TEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TEXT_MENU, TextMenuClass))
#define IS_TEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEXT_MENU))
#define IS_TEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TEXT_MENU))
#define TEXT_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TEXT_MENU, TextMenuClass))

typedef struct _TextMenu TextMenu;
typedef struct _TextMenuClass TextMenuClass;
typedef struct _TextMenuPrivate TextMenuPrivate;

#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;
typedef enum  {
	KEY_COMMAND_DO_NOTHING,
	KEY_COMMAND_GENERAL_START,
	KEY_COMMAND_FILE_START,
	KEY_COMMAND_FILE_NEW,
	KEY_COMMAND_FILE_OPEN,
	KEY_COMMAND_FILE_OPEN_DIR,
	KEY_COMMAND_FILE_SAVE,
	KEY_COMMAND_FILE_SAVE_AS,
	KEY_COMMAND_FILE_PRINT,
	KEY_COMMAND_FILE_END,
	KEY_COMMAND_TAB_START,
	KEY_COMMAND_TAB_GOTO_NEXT,
	KEY_COMMAND_TAB_GOTO_PREV,
	KEY_COMMAND_TAB_CLOSE_CURRENT,
	KEY_COMMAND_TAB_END,
	KEY_COMMAND_UNDO_START,
	KEY_COMMAND_UNDO_ACTION,
	KEY_COMMAND_REDO_ACTION,
	KEY_COMMAND_UNDO_END,
	KEY_COMMAND_ZOOM_START,
	KEY_COMMAND_ZOOM_IN,
	KEY_COMMAND_ZOOM_OUT,
	KEY_COMMAND_ZOOM_FIT,
	KEY_COMMAND_ZOOM_SELECTED,
	KEY_COMMAND_ZOOM_ACTUAL,
	KEY_COMMAND_ZOOM_END,
	KEY_COMMAND_SIDEBAR_START,
	KEY_COMMAND_SHOW_CURRENT_SIDEBAR,
	KEY_COMMAND_SHOW_STYLE_SIDEBAR,
	KEY_COMMAND_SHOW_TAG_SIDEBAR,
	KEY_COMMAND_SHOW_STICKER_SIDEBAR,
	KEY_COMMAND_SHOW_MAP_SIDEBAR,
	KEY_COMMAND_SHOW_CURRENT_INFO,
	KEY_COMMAND_SIDEBAR_END,
	KEY_COMMAND_MAP_START,
	KEY_COMMAND_TOGGLE_CONNECTIONS,
	KEY_COMMAND_TOGGLE_CALLOUTS,
	KEY_COMMAND_BALANCE_NODES,
	KEY_COMMAND_FOLD_COMPLETED_TASKS,
	KEY_COMMAND_UNFOLD_ALL_NODES,
	KEY_COMMAND_MAP_END,
	KEY_COMMAND_MISCELLANEOUS_START,
	KEY_COMMAND_SHOW_PREFERENCES,
	KEY_COMMAND_SHOW_SHORTCUTS,
	KEY_COMMAND_SHOW_CONTEXTUAL_MENU,
	KEY_COMMAND_SHOW_FIND,
	KEY_COMMAND_SHOW_ABOUT,
	KEY_COMMAND_TOGGLE_BRAINDUMP,
	KEY_COMMAND_TOGGLE_FOCUS_MODE,
	KEY_COMMAND_EDIT_NOTE,
	KEY_COMMAND_EDIT_SELECTED,
	KEY_COMMAND_SHOW_SELECTED,
	KEY_COMMAND_REMOVE_STICKER_SELECTED,
	KEY_COMMAND_QUIT,
	KEY_COMMAND_MISCELLANEOUS_END,
	KEY_COMMAND_CONTROL_PRESSED,
	KEY_COMMAND_ESCAPE,
	KEY_COMMAND_GENERAL_END,
	KEY_COMMAND_NODE_START,
	KEY_COMMAND_NODE_EXIST_START,
	KEY_COMMAND_NODE_ADD_ROOT,
	KEY_COMMAND_NODE_ADD_SIBLING_AFTER,
	KEY_COMMAND_NODE_ADD_SIBLING_BEFORE,
	KEY_COMMAND_NODE_ADD_CHILD,
	KEY_COMMAND_NODE_ADD_PARENT,
	KEY_COMMAND_NODE_QUICK_ENTRY_INSERT,
	KEY_COMMAND_NODE_QUICK_ENTRY_REPLACE,
	KEY_COMMAND_NODE_REMOVE,
	KEY_COMMAND_NODE_REMOVE_ONLY,
	KEY_COMMAND_NODE_EXIST_END,
	KEY_COMMAND_NODE_CLIPBOARD_START,
	KEY_COMMAND_NODE_PASTE_NODE_LINK,
	KEY_COMMAND_NODE_PASTE_REPLACE,
	KEY_COMMAND_NODE_CLIPBOARD_END,
	KEY_COMMAND_NODE_VIEW_START,
	KEY_COMMAND_NODE_CENTER,
	KEY_COMMAND_NODE_VIEW_END,
	KEY_COMMAND_NODE_CHANGE_START,
	KEY_COMMAND_NODE_CHANGE_TASK,
	KEY_COMMAND_NODE_CHANGE_IMAGE,
	KEY_COMMAND_NODE_REMOVE_IMAGE,
	KEY_COMMAND_NODE_CHANGE_LINK_COLOR,
	KEY_COMMAND_NODE_RANDOMIZE_LINK_COLOR,
	KEY_COMMAND_NODE_REPARENT_LINK_COLOR,
	KEY_COMMAND_NODE_TOGGLE_FOLDS_SHALLOW,
	KEY_COMMAND_NODE_TOGGLE_FOLDS_DEEP,
	KEY_COMMAND_NODE_TOGGLE_LINKS,
	KEY_COMMAND_NODE_ADD_GROUP,
	KEY_COMMAND_NODE_ADD_CONNECTION,
	KEY_COMMAND_NODE_TOGGLE_CALLOUT,
	KEY_COMMAND_NODE_TOGGLE_SEQUENCE,
	KEY_COMMAND_NODE_CHANGE_END,
	KEY_COMMAND_NODE_SELECT_START,
	KEY_COMMAND_NODE_SELECT_ROOT,
	KEY_COMMAND_NODE_SELECT_PARENT,
	KEY_COMMAND_NODE_SELECT_SIBLING_NEXT,
	KEY_COMMAND_NODE_SELECT_SIBLING_PREV,
	KEY_COMMAND_NODE_SELECT_CHILD,
	KEY_COMMAND_NODE_SELECT_CHILDREN,
	KEY_COMMAND_NODE_SELECT_TREE,
	KEY_COMMAND_NODE_SELECT_DOWN,
	KEY_COMMAND_NODE_SELECT_UP,
	KEY_COMMAND_NODE_SELECT_RIGHT,
	KEY_COMMAND_NODE_SELECT_LEFT,
	KEY_COMMAND_NODE_SELECT_LINKED,
	KEY_COMMAND_NODE_SELECT_CALLOUT,
	KEY_COMMAND_NODE_SELECT_CONNECTION,
	KEY_COMMAND_NODE_SELECT_END,
	KEY_COMMAND_NODE_MOVE_START,
	KEY_COMMAND_NODE_SWAP_RIGHT,
	KEY_COMMAND_NODE_SWAP_LEFT,
	KEY_COMMAND_NODE_SWAP_UP,
	KEY_COMMAND_NODE_SWAP_DOWN,
	KEY_COMMAND_NODE_SORT_ALPHABETICALLY,
	KEY_COMMAND_NODE_SORT_RANDOMLY,
	KEY_COMMAND_NODE_DETACH,
	KEY_COMMAND_NODE_MOVE_END,
	KEY_COMMAND_NODE_ALIGN_START,
	KEY_COMMAND_NODE_ALIGN_TOP,
	KEY_COMMAND_NODE_ALIGN_VCENTER,
	KEY_COMMAND_NODE_ALIGN_BOTTOM,
	KEY_COMMAND_NODE_ALIGN_LEFT,
	KEY_COMMAND_NODE_ALIGN_HCENTER,
	KEY_COMMAND_NODE_ALIGN_RIGHT,
	KEY_COMMAND_NODE_ALIGN_END,
	KEY_COMMAND_NODE_END,
	KEY_COMMAND_CALLOUT_START,
	KEY_COMMAND_CALLOUT_SELECT_START,
	KEY_COMMAND_CALLOUT_SELECT_NODE,
	KEY_COMMAND_CALLOUT_SELECT_END,
	KEY_COMMAND_CALLOUT_REMOVE,
	KEY_COMMAND_CALLOUT_END,
	KEY_COMMAND_CONNECTION_START,
	KEY_COMMAND_CONNECTION_EXIST_START,
	KEY_COMMAND_CONNECTION_REMOVE,
	KEY_COMMAND_CONNECTION_EXIST_END,
	KEY_COMMAND_CONNECTION_SELECT_START,
	KEY_COMMAND_CONNECTION_SELECT_FROM,
	KEY_COMMAND_CONNECTION_SELECT_TO,
	KEY_COMMAND_CONNECTION_SELECT_NEXT,
	KEY_COMMAND_CONNECTION_SELECT_PREV,
	KEY_COMMAND_CONNECTION_SELECT_END,
	KEY_COMMAND_CONNECTION_END,
	KEY_COMMAND_STICKER_START,
	KEY_COMMAND_STICKER_REMOVE,
	KEY_COMMAND_STICKER_END,
	KEY_COMMAND_GROUP_START,
	KEY_COMMAND_GROUP_CHANGE_START,
	KEY_COMMAND_GROUP_CHANGE_COLOR,
	KEY_COMMAND_GROUP_MERGE,
	KEY_COMMAND_GROUP_REMOVE,
	KEY_COMMAND_GROUP_CHANGE_END,
	KEY_COMMAND_GROUP_SELECT_START,
	KEY_COMMAND_GROUP_SELECT_MAIN,
	KEY_COMMAND_GROUP_SELECT_ALL,
	KEY_COMMAND_GROUP_SELECT_END,
	KEY_COMMAND_GROUP_END,
	KEY_COMMAND_EDIT_START,
	KEY_COMMAND_EDIT_TEXT_START,
	KEY_COMMAND_EDIT_INSERT_NEWLINE,
	KEY_COMMAND_EDIT_INSERT_TAB,
	KEY_COMMAND_EDIT_INSERT_EMOJI,
	KEY_COMMAND_EDIT_ESCAPE,
	KEY_COMMAND_EDIT_BACKSPACE,
	KEY_COMMAND_EDIT_DELETE,
	KEY_COMMAND_EDIT_REMOVE_WORD_NEXT,
	KEY_COMMAND_EDIT_REMOVE_WORD_PREV,
	KEY_COMMAND_EDIT_TEXT_END,
	KEY_COMMAND_EDIT_MARKDOWN_START,
	KEY_COMMAND_EDIT_HEADER1,
	KEY_COMMAND_EDIT_HEADER2,
	KEY_COMMAND_EDIT_HEADER3,
	KEY_COMMAND_EDIT_HEADER4,
	KEY_COMMAND_EDIT_HEADER5,
	KEY_COMMAND_EDIT_HEADER6,
	KEY_COMMAND_EDIT_BOLD,
	KEY_COMMAND_EDIT_ITALICS,
	KEY_COMMAND_EDIT_STRIKE,
	KEY_COMMAND_EDIT_CODE,
	KEY_COMMAND_EDIT_HIGHLIGHT,
	KEY_COMMAND_EDIT_SUPERSCRIPT,
	KEY_COMMAND_EDIT_SUBSCRIPT,
	KEY_COMMAND_EDIT_LINK,
	KEY_COMMAND_EDIT_MARKDOWN_END,
	KEY_COMMAND_EDIT_CLIPBOARD_START,
	KEY_COMMAND_EDIT_COPY,
	KEY_COMMAND_EDIT_CUT,
	KEY_COMMAND_EDIT_PASTE,
	KEY_COMMAND_EDIT_CLIPBOARD_END,
	KEY_COMMAND_EDIT_URL_START,
	KEY_COMMAND_EDIT_OPEN_URL,
	KEY_COMMAND_EDIT_ADD_URL,
	KEY_COMMAND_EDIT_EDIT_URL,
	KEY_COMMAND_EDIT_REMOVE_URL,
	KEY_COMMAND_EDIT_URL_END,
	KEY_COMMAND_EDIT_CURSOR_START,
	KEY_COMMAND_EDIT_CURSOR_CHAR_NEXT,
	KEY_COMMAND_EDIT_CURSOR_CHAR_PREV,
	KEY_COMMAND_EDIT_CURSOR_UP,
	KEY_COMMAND_EDIT_CURSOR_DOWN,
	KEY_COMMAND_EDIT_CURSOR_WORD_NEXT,
	KEY_COMMAND_EDIT_CURSOR_WORD_PREV,
	KEY_COMMAND_EDIT_CURSOR_FIRST,
	KEY_COMMAND_EDIT_CURSOR_LAST,
	KEY_COMMAND_EDIT_CURSOR_LINESTART,
	KEY_COMMAND_EDIT_CURSOR_LINEEND,
	KEY_COMMAND_EDIT_CURSOR_END,
	KEY_COMMAND_EDIT_SELECT_START,
	KEY_COMMAND_EDIT_SELECT_CHAR_NEXT,
	KEY_COMMAND_EDIT_SELECT_CHAR_PREV,
	KEY_COMMAND_EDIT_SELECT_UP,
	KEY_COMMAND_EDIT_SELECT_DOWN,
	KEY_COMMAND_EDIT_SELECT_WORD_NEXT,
	KEY_COMMAND_EDIT_SELECT_WORD_PREV,
	KEY_COMMAND_EDIT_SELECT_START_UP,
	KEY_COMMAND_EDIT_SELECT_START_HOME,
	KEY_COMMAND_EDIT_SELECT_END_DOWN,
	KEY_COMMAND_EDIT_SELECT_END_END,
	KEY_COMMAND_EDIT_SELECT_LINESTART,
	KEY_COMMAND_EDIT_SELECT_LINEEND,
	KEY_COMMAND_EDIT_SELECT_ALL,
	KEY_COMMAND_EDIT_SELECT_NONE,
	KEY_COMMAND_EDIT_SELECT_END,
	KEY_COMMAND_EDIT_MISC_START,
	KEY_COMMAND_EDIT_RETURN,
	KEY_COMMAND_EDIT_SHIFT_RETURN,
	KEY_COMMAND_EDIT_TAB,
	KEY_COMMAND_EDIT_SHIFT_TAB,
	KEY_COMMAND_EDIT_MISC_END,
	KEY_COMMAND_EDIT_END,
	KEY_COMMAND_NUM
} KeyCommand;

#define TYPE_KEY_COMMAND (key_command_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (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_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 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;
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 _g_free0(var) (var = (g_free (var), NULL))

#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;
#define _undo_tag_info_unref0(var) ((var == NULL) ? NULL : (var = (undo_tag_info_unref (var), NULL)))
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))

struct _BaseMenu {
	GTypeInstance parent_instance;
	volatile int ref_count;
	BaseMenuPrivate * priv;
};

struct _BaseMenuClass {
	GTypeClass parent_class;
	void (*finalize) (BaseMenu *self);
	void (*on_popup) (BaseMenu* self);
	void (*on_popdown) (BaseMenu* self);
};

struct _TextMenu {
	BaseMenu parent_instance;
	TextMenuPrivate * priv;
};

struct _TextMenuClass {
	BaseMenuClass parent_class;
};

struct _TextMenuPrivate {
	gboolean _clear_selection;
};

static gint TextMenu_private_offset;
static gpointer text_menu_parent_class = NULL;
VALA_EXTERN GSettings* minder_settings;

VALA_EXTERN gpointer base_menu_ref (gpointer instance);
VALA_EXTERN void base_menu_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_base_menu (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags);
VALA_EXTERN void value_set_base_menu (GValue* value,
                          gpointer v_object);
VALA_EXTERN void value_take_base_menu (GValue* value,
                           gpointer v_object);
VALA_EXTERN gpointer value_get_base_menu (const GValue* value);
VALA_EXTERN GType base_menu_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BaseMenu, base_menu_unref)
VALA_EXTERN GType text_menu_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TextMenu, base_menu_unref)
VALA_EXTERN void base_menu_on_popup (BaseMenu* self);
VALA_EXTERN void base_menu_on_popdown (BaseMenu* self);
VALA_EXTERN GType draw_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DrawArea, g_object_unref)
VALA_EXTERN TextMenu* text_menu_new (GtkApplication* app,
                         DrawArea* da);
VALA_EXTERN TextMenu* text_menu_construct (GType object_type,
                               GtkApplication* app,
                               DrawArea* da);
VALA_EXTERN BaseMenu* base_menu_new (GtkApplication* app,
                         DrawArea* canvas,
                         const gchar* group);
VALA_EXTERN BaseMenu* base_menu_construct (GType object_type,
                               GtkApplication* app,
                               DrawArea* canvas,
                               const gchar* group);
VALA_EXTERN GType key_command_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void base_menu_append_menu_item (BaseMenu* self,
                                 GMenu* menu,
                                 KeyCommand command,
                                 const gchar* label,
                                 gboolean grab_canvas);
VALA_EXTERN GMenu* base_menu_get_menu (BaseMenu* self);
static void text_menu_real_on_popup (BaseMenu* base);
VALA_EXTERN GType canvas_text_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CanvasText, g_object_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 MindMap* base_menu_get_map (BaseMenu* self);
VALA_EXTERN CanvasText* mind_map_get_current_text (MindMap* self);
VALA_EXTERN void canvas_text_get_cursor_info (CanvasText* self,
                                  gint* cursor,
                                  gint* start,
                                  gint* end);
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 GType format_tag_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GArray* formatted_text_get_full_tags_in_range (FormattedText* self,
                                               FormatTag tag,
                                               gint start,
                                               gint end);
VALA_EXTERN const gchar* undo_tag_info_get_extra (UndoTagInfo* self);
VALA_EXTERN const gchar* formatted_text_get_text (FormattedText* self);
VALA_EXTERN gint undo_tag_info_get_start (UndoTagInfo* self);
VALA_EXTERN gint undo_tag_info_get_end (UndoTagInfo* self);
VALA_EXTERN void canvas_text_change_selection (CanvasText* self,
                                   gint* selstart,
                                   gint* selend,
                                   const gchar* msg);
VALA_EXTERN void base_menu_set_enabled (BaseMenu* self,
                            KeyCommand command,
                            gboolean enable);
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 gboolean map_model_add_link_possible (MapModel* self,
                                      CanvasText* ct);
static gboolean text_menu_copy_or_cut_possible (TextMenu* self);
static gboolean text_menu_paste_possible (TextMenu* self);
static void text_menu_real_on_popdown (BaseMenu* base);
VALA_EXTERN void canvas_text_clear_selection (CanvasText* self,
                                  const gchar* msg);
VALA_EXTERN gboolean minder_clipboard_text_pasteable (void);
static void text_menu_finalize (BaseMenu * obj);
static GType text_menu_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
text_menu_get_instance_private (TextMenu* self)
{
	return G_STRUCT_MEMBER_P (self, TextMenu_private_offset);
}

TextMenu*
text_menu_construct (GType object_type,
                     GtkApplication* app,
                     DrawArea* da)
{
	TextMenu* self = NULL;
	GMenu* edit_menu = NULL;
	GMenu* _tmp0_;
	GMenu* emoji_menu = NULL;
	GMenu* _tmp1_;
	GMenu* open_menu = NULL;
	GMenu* _tmp2_;
	GMenu* other_menu = NULL;
	GMenu* _tmp3_;
	GMenu* md_menu = NULL;
	GMenu* _tmp4_;
	GMenu* md_submenu = NULL;
	GMenu* _tmp5_;
	GMenu* _tmp6_;
	GMenu* _tmp7_;
	GMenu* _tmp8_;
	GMenu* _tmp9_;
	GMenu* _tmp10_;
	GMenu* _tmp11_;
	GMenu* _tmp12_;
	GMenu* _tmp13_;
	GMenu* _tmp14_;
	GMenu* _tmp15_;
	g_return_val_if_fail (app != NULL, NULL);
	g_return_val_if_fail (da != NULL, NULL);
	self = (TextMenu*) base_menu_construct (object_type, app, da, "text");
	_tmp0_ = g_menu_new ();
	edit_menu = _tmp0_;
	base_menu_append_menu_item ((BaseMenu*) self, edit_menu, KEY_COMMAND_EDIT_COPY, _ ("Copy"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, edit_menu, KEY_COMMAND_EDIT_CUT, _ ("Cut"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, edit_menu, KEY_COMMAND_EDIT_PASTE, _ ("Paste"), TRUE);
	_tmp1_ = g_menu_new ();
	emoji_menu = _tmp1_;
	base_menu_append_menu_item ((BaseMenu*) self, emoji_menu, KEY_COMMAND_EDIT_INSERT_EMOJI, _ ("Insert Emoji"), TRUE);
	_tmp2_ = g_menu_new ();
	open_menu = _tmp2_;
	base_menu_append_menu_item ((BaseMenu*) self, open_menu, KEY_COMMAND_EDIT_OPEN_URL, _ ("Open Link"), TRUE);
	_tmp3_ = g_menu_new ();
	other_menu = _tmp3_;
	base_menu_append_menu_item ((BaseMenu*) self, other_menu, KEY_COMMAND_EDIT_ADD_URL, _ ("Add Link"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, other_menu, KEY_COMMAND_EDIT_EDIT_URL, _ ("Edit Link"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, other_menu, KEY_COMMAND_EDIT_REMOVE_URL, _ ("Remove Link"), TRUE);
	_tmp4_ = g_menu_new ();
	md_menu = _tmp4_;
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_HEADER1, _ ("# Header1"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_HEADER2, _ ("## Header2"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_HEADER3, _ ("### Header3"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_HEADER4, _ ("#### Header4"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_HEADER5, _ ("##### Header5"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_HEADER6, _ ("###### Header6"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_BOLD, _ ("**Bold**"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_ITALICS, _ ("__Italicize_"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_STRIKE, _ ("~~Strikeout~~"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_CODE, _ ("`Code`"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_HIGHLIGHT, _ ("==Highlight=="), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_SUPERSCRIPT, _ ("<sup>Superscript</sup>"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_SUBSCRIPT, _ ("<sub>Subscript</sub>"), TRUE);
	base_menu_append_menu_item ((BaseMenu*) self, md_menu, KEY_COMMAND_EDIT_LINK, _ ("[Link text](URL)"), TRUE);
	_tmp5_ = g_menu_new ();
	md_submenu = _tmp5_;
	g_menu_append_submenu (md_submenu, _ ("Markdown"), (GMenuModel*) md_menu);
	_tmp6_ = base_menu_get_menu ((BaseMenu*) self);
	_tmp7_ = _tmp6_;
	g_menu_append_section (_tmp7_, NULL, (GMenuModel*) edit_menu);
	_tmp8_ = base_menu_get_menu ((BaseMenu*) self);
	_tmp9_ = _tmp8_;
	g_menu_append_section (_tmp9_, NULL, (GMenuModel*) emoji_menu);
	_tmp10_ = base_menu_get_menu ((BaseMenu*) self);
	_tmp11_ = _tmp10_;
	g_menu_append_section (_tmp11_, NULL, (GMenuModel*) open_menu);
	_tmp12_ = base_menu_get_menu ((BaseMenu*) self);
	_tmp13_ = _tmp12_;
	g_menu_append_section (_tmp13_, NULL, (GMenuModel*) other_menu);
	_tmp14_ = base_menu_get_menu ((BaseMenu*) self);
	_tmp15_ = _tmp14_;
	g_menu_append_section (_tmp15_, NULL, (GMenuModel*) md_submenu);
	_g_object_unref0 (md_submenu);
	_g_object_unref0 (md_menu);
	_g_object_unref0 (other_menu);
	_g_object_unref0 (open_menu);
	_g_object_unref0 (emoji_menu);
	_g_object_unref0 (edit_menu);
	return self;
}

TextMenu*
text_menu_new (GtkApplication* app,
               DrawArea* da)
{
	return text_menu_construct (TYPE_TEXT_MENU, app, da);
}

static gpointer
_undo_tag_info_ref0 (gpointer self)
{
	return self ? undo_tag_info_ref (self) : NULL;
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static void
text_menu_real_on_popup (BaseMenu* base)
{
	TextMenu * self;
	CanvasText* text = NULL;
	MindMap* _tmp0_;
	MindMap* _tmp1_;
	CanvasText* _tmp2_;
	CanvasText* _tmp3_;
	gboolean copy_or_cut = FALSE;
	gboolean md_enabled = FALSE;
	GSettings* _tmp54_;
	self = (TextMenu*) base;
	_tmp0_ = base_menu_get_map ((BaseMenu*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = mind_map_get_current_text (_tmp1_);
	text = _tmp2_;
	_tmp3_ = text;
	if (_tmp3_ != NULL) {
		gint cursor = 0;
		gint selstart = 0;
		gint selend = 0;
		CanvasText* _tmp4_;
		gint _tmp5_ = 0;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		GArray* links = NULL;
		CanvasText* _tmp8_;
		FormattedText* _tmp9_;
		FormattedText* _tmp10_;
		GArray* _tmp11_;
		UndoTagInfo* _tmp12_ = NULL;
		GArray* _tmp13_;
		UndoTagInfo* link = NULL;
		UndoTagInfo* _tmp16_;
		gboolean valid = FALSE;
		UndoTagInfo* _tmp17_;
		gboolean selected = FALSE;
		gboolean _tmp18_ = FALSE;
		GArray* _tmp19_;
		gboolean embedded = FALSE;
		gboolean _tmp36_ = FALSE;
		gboolean _tmp44_ = FALSE;
		gboolean _tmp50_ = FALSE;
		gboolean _tmp51_ = FALSE;
		gboolean _tmp52_ = FALSE;
		gboolean _tmp53_ = FALSE;
		_tmp4_ = text;
		canvas_text_get_cursor_info (_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
		cursor = _tmp5_;
		selstart = _tmp6_;
		selend = _tmp7_;
		_tmp8_ = text;
		_tmp9_ = canvas_text_get_text (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = formatted_text_get_full_tags_in_range (_tmp10_, FORMAT_TAG_URL, cursor, cursor);
		links = _tmp11_;
		_tmp13_ = links;
		if (_tmp13_->len > ((guint) 0)) {
			GArray* _tmp14_;
			UndoTagInfo* _tmp15_;
			_tmp14_ = links;
			_tmp15_ = g_array_index (_tmp14_, UndoTagInfo*, (guint) 0);
			_tmp12_ = _tmp15_;
		} else {
			_tmp12_ = NULL;
		}
		_tmp16_ = _undo_tag_info_ref0 (_tmp12_);
		link = _tmp16_;
		_tmp17_ = link;
		valid = _tmp17_ != NULL;
		selected = selstart != selend;
		_tmp19_ = links;
		if (_tmp19_->len > ((guint) 0)) {
			UndoTagInfo* _tmp20_;
			const gchar* _tmp21_;
			const gchar* _tmp22_;
			CanvasText* _tmp23_;
			FormattedText* _tmp24_;
			FormattedText* _tmp25_;
			const gchar* _tmp26_;
			const gchar* _tmp27_;
			UndoTagInfo* _tmp28_;
			gint _tmp29_;
			gint _tmp30_;
			UndoTagInfo* _tmp31_;
			gint _tmp32_;
			gint _tmp33_;
			gchar* _tmp34_;
			gchar* _tmp35_;
			_tmp20_ = link;
			_tmp21_ = undo_tag_info_get_extra (_tmp20_);
			_tmp22_ = _tmp21_;
			_tmp23_ = text;
			_tmp24_ = canvas_text_get_text (_tmp23_);
			_tmp25_ = _tmp24_;
			_tmp26_ = formatted_text_get_text (_tmp25_);
			_tmp27_ = _tmp26_;
			_tmp28_ = link;
			_tmp29_ = undo_tag_info_get_start (_tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = link;
			_tmp32_ = undo_tag_info_get_end (_tmp31_);
			_tmp33_ = _tmp32_;
			_tmp34_ = string_slice (_tmp27_, (glong) _tmp30_, (glong) _tmp33_);
			_tmp35_ = _tmp34_;
			_tmp18_ = g_strcmp0 (_tmp22_, _tmp35_) == 0;
			_g_free0 (_tmp35_);
		} else {
			_tmp18_ = FALSE;
		}
		embedded = _tmp18_;
		if (valid) {
			_tmp36_ = !selected;
		} else {
			_tmp36_ = FALSE;
		}
		if (_tmp36_) {
			CanvasText* _tmp37_;
			UndoTagInfo* _tmp38_;
			gint _tmp39_;
			gint _tmp40_;
			UndoTagInfo* _tmp41_;
			gint _tmp42_;
			gint _tmp43_;
			_tmp37_ = text;
			_tmp38_ = link;
			_tmp39_ = undo_tag_info_get_start (_tmp38_);
			_tmp40_ = _tmp39_;
			_tmp41_ = link;
			_tmp42_ = undo_tag_info_get_end (_tmp41_);
			_tmp43_ = _tmp42_;
			canvas_text_change_selection (_tmp37_, &_tmp40_, &_tmp43_, NULL);
		}
		base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_OPEN_URL, valid);
		if (!embedded) {
			MindMap* _tmp45_;
			MindMap* _tmp46_;
			MapModel* _tmp47_;
			MapModel* _tmp48_;
			CanvasText* _tmp49_;
			_tmp45_ = base_menu_get_map ((BaseMenu*) self);
			_tmp46_ = _tmp45_;
			_tmp47_ = mind_map_get_model (_tmp46_);
			_tmp48_ = _tmp47_;
			_tmp49_ = text;
			_tmp44_ = map_model_add_link_possible (_tmp48_, _tmp49_);
		} else {
			_tmp44_ = FALSE;
		}
		base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_ADD_URL, _tmp44_);
		if (valid) {
			_tmp51_ = !selected;
		} else {
			_tmp51_ = FALSE;
		}
		if (_tmp51_) {
			_tmp50_ = !embedded;
		} else {
			_tmp50_ = FALSE;
		}
		base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_EDIT_URL, _tmp50_);
		if (valid) {
			_tmp52_ = !selected;
		} else {
			_tmp52_ = FALSE;
		}
		base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_REMOVE_URL, _tmp52_);
		if (valid) {
			_tmp53_ = !selected;
		} else {
			_tmp53_ = FALSE;
		}
		self->priv->_clear_selection = _tmp53_;
		_undo_tag_info_unref0 (link);
		_g_array_unref0 (links);
	} else {
		base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_OPEN_URL, FALSE);
		base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_ADD_URL, FALSE);
		base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_EDIT_URL, FALSE);
		base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_REMOVE_URL, FALSE);
		self->priv->_clear_selection = FALSE;
	}
	copy_or_cut = text_menu_copy_or_cut_possible (self);
	base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_COPY, copy_or_cut);
	base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_CUT, copy_or_cut);
	base_menu_set_enabled ((BaseMenu*) self, KEY_COMMAND_EDIT_PASTE, text_menu_paste_possible (self));
	_tmp54_ = minder_settings;
	md_enabled = g_settings_get_boolean (_tmp54_, "enable-markdown");
	{
		gint i = 0;
		i = (gint) (KEY_COMMAND_EDIT_MARKDOWN_START + 1);
		{
			gboolean _tmp55_ = FALSE;
			_tmp55_ = TRUE;
			while (TRUE) {
				if (!_tmp55_) {
					gint _tmp56_;
					_tmp56_ = i;
					i = _tmp56_ + 1;
				}
				_tmp55_ = FALSE;
				if (!(i < ((gint) KEY_COMMAND_EDIT_MARKDOWN_END))) {
					break;
				}
				base_menu_set_enabled ((BaseMenu*) self, (KeyCommand) i, md_enabled);
			}
		}
	}
	_g_object_unref0 (text);
}

static void
text_menu_real_on_popdown (BaseMenu* base)
{
	TextMenu * self;
	self = (TextMenu*) base;
	if (self->priv->_clear_selection) {
		CanvasText* text = NULL;
		MindMap* _tmp0_;
		MindMap* _tmp1_;
		CanvasText* _tmp2_;
		CanvasText* _tmp3_;
		_tmp0_ = base_menu_get_map ((BaseMenu*) self);
		_tmp1_ = _tmp0_;
		_tmp2_ = mind_map_get_current_text (_tmp1_);
		text = _tmp2_;
		_tmp3_ = text;
		if (_tmp3_ != NULL) {
			CanvasText* _tmp4_;
			_tmp4_ = text;
			canvas_text_clear_selection (_tmp4_, NULL);
		}
		_g_object_unref0 (text);
	}
}

static gboolean
text_menu_copy_or_cut_possible (TextMenu* self)
{
	CanvasText* text = NULL;
	MindMap* _tmp0_;
	MindMap* _tmp1_;
	CanvasText* _tmp2_;
	gint cursor = 0;
	gint selstart = 0;
	gint selend = 0;
	CanvasText* _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = base_menu_get_map ((BaseMenu*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = mind_map_get_current_text (_tmp1_);
	text = _tmp2_;
	cursor = 0;
	selstart = 0;
	selend = 0;
	_tmp3_ = text;
	if (_tmp3_ != NULL) {
		CanvasText* _tmp4_;
		gint _tmp5_ = 0;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		_tmp4_ = text;
		canvas_text_get_cursor_info (_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
		cursor = _tmp5_;
		selstart = _tmp6_;
		selend = _tmp7_;
	}
	result = selstart != selend;
	_g_object_unref0 (text);
	return result;
}

static gboolean
text_menu_paste_possible (TextMenu* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = minder_clipboard_text_pasteable ();
	return result;
}

static void
text_menu_class_init (TextMenuClass * klass,
                      gpointer klass_data)
{
	text_menu_parent_class = g_type_class_peek_parent (klass);
	((BaseMenuClass *) klass)->finalize = text_menu_finalize;
	g_type_class_adjust_private_offset (klass, &TextMenu_private_offset);
	((BaseMenuClass *) klass)->on_popup = (void (*) (BaseMenu*)) text_menu_real_on_popup;
	((BaseMenuClass *) klass)->on_popdown = (void (*) (BaseMenu*)) text_menu_real_on_popdown;
}

static void
text_menu_instance_init (TextMenu * self,
                         gpointer klass)
{
	self->priv = text_menu_get_instance_private (self);
	self->priv->_clear_selection = FALSE;
}

static void
text_menu_finalize (BaseMenu * obj)
{
	TextMenu * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TEXT_MENU, TextMenu);
	BASE_MENU_CLASS (text_menu_parent_class)->finalize (obj);
}

static GType
text_menu_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TextMenuClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) text_menu_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TextMenu), 0, (GInstanceInitFunc) text_menu_instance_init, NULL };
	GType text_menu_type_id;
	text_menu_type_id = g_type_register_static (TYPE_BASE_MENU, "TextMenu", &g_define_type_info, 0);
	TextMenu_private_offset = g_type_add_instance_private (text_menu_type_id, sizeof (TextMenuPrivate));
	return text_menu_type_id;
}

GType
text_menu_get_type (void)
{
	static volatile gsize text_menu_type_id__once = 0;
	if (g_once_init_enter (&text_menu_type_id__once)) {
		GType text_menu_type_id;
		text_menu_type_id = text_menu_get_type_once ();
		g_once_init_leave (&text_menu_type_id__once, text_menu_type_id);
	}
	return text_menu_type_id__once;
}

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

