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

/*
 * This file is part of GNOME LaTeX.
 *
 * Copyright © 2012 Sébastien Wilmet
 *
 * GNOME LaTeX is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GNOME LaTeX 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 GNOME LaTeX.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Sébastien Wilmet
 */

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include "config.h"
#include <gdk/gdk.h>
#include <gobject/gvaluecollector.h>

#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_MAIN_WINDOW_STRUCTURE (main_window_structure_get_type ())
#define MAIN_WINDOW_STRUCTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW_STRUCTURE, MainWindowStructure))
#define MAIN_WINDOW_STRUCTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW_STRUCTURE, MainWindowStructureClass))
#define IS_MAIN_WINDOW_STRUCTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW_STRUCTURE))
#define IS_MAIN_WINDOW_STRUCTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW_STRUCTURE))
#define MAIN_WINDOW_STRUCTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW_STRUCTURE, MainWindowStructureClass))

typedef struct _MainWindowStructure MainWindowStructure;
typedef struct _MainWindowStructureClass MainWindowStructureClass;
typedef struct _MainWindowStructurePrivate MainWindowStructurePrivate;

#define TYPE_STRUCTURE (structure_get_type ())
#define STRUCTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_STRUCTURE, Structure))
#define STRUCTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_STRUCTURE, StructureClass))
#define IS_STRUCTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_STRUCTURE))
#define IS_STRUCTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_STRUCTURE))
#define STRUCTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_STRUCTURE, StructureClass))

typedef struct _Structure Structure;
typedef struct _StructureClass StructureClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef enum  {
	STRUCT_TYPE_BEGIN_COMMON_TYPES,
	STRUCT_TYPE_PART,
	STRUCT_TYPE_CHAPTER,
	STRUCT_TYPE_SECTION,
	STRUCT_TYPE_SUBSECTION,
	STRUCT_TYPE_SUBSUBSECTION,
	STRUCT_TYPE_PARAGRAPH,
	STRUCT_TYPE_SUBPARAGRAPH,
	STRUCT_TYPE_LABEL,
	STRUCT_TYPE_INCLUDE,
	STRUCT_TYPE_IMAGE,
	STRUCT_TYPE_TODO,
	STRUCT_TYPE_FIXME,
	STRUCT_TYPE_END_COMMON_TYPES,
	STRUCT_TYPE_BEGIN_LOW_LEVEL_TYPES,
	STRUCT_TYPE_BEGIN_FIGURE,
	STRUCT_TYPE_END_FIGURE,
	STRUCT_TYPE_BEGIN_TABLE,
	STRUCT_TYPE_END_TABLE,
	STRUCT_TYPE_BEGIN_VERBATIM,
	STRUCT_TYPE_END_VERBATIM,
	STRUCT_TYPE_END_DOCUMENT,
	STRUCT_TYPE_CAPTION,
	STRUCT_TYPE_END_LOW_LEVEL_TYPES,
	STRUCT_TYPE_BEGIN_HIGH_LEVEL_TYPES,
	STRUCT_TYPE_TABLE,
	STRUCT_TYPE_FIGURE,
	STRUCT_TYPE_END_HIGH_LEVEL_TYPES,
	STRUCT_TYPE_NB_TYPES
} StructType;

#define TYPE_STRUCT_TYPE (struct_type_get_type ())
typedef enum  {
	STRUCT_ACTION_CUT,
	STRUCT_ACTION_COPY,
	STRUCT_ACTION_DELETE,
	STRUCT_ACTION_SELECT,
	STRUCT_ACTION_COMMENT,
	STRUCT_ACTION_SHIFT_LEFT,
	STRUCT_ACTION_SHIFT_RIGHT,
	STRUCT_ACTION_OPEN_FILE,
	STRUCT_ACTION_NB_ACTIONS
} StructAction;

#define TYPE_STRUCT_ACTION (struct_action_get_type ())
typedef struct _ParamSpecMainWindowStructure ParamSpecMainWindowStructure;

struct _MainWindowStructure {
	GTypeInstance parent_instance;
	volatile int ref_count;
	MainWindowStructurePrivate * priv;
};

struct _MainWindowStructureClass {
	GTypeClass parent_class;
	void (*finalize) (MainWindowStructure *self);
};

struct _MainWindowStructurePrivate {
	GtkUIManager* _ui_manager;
	Structure* _structure;
};

struct _ParamSpecMainWindowStructure {
	GParamSpec parent_instance;
};

static gint MainWindowStructure_private_offset;
static gpointer main_window_structure_parent_class = NULL;

VALA_EXTERN gpointer main_window_structure_ref (gpointer instance);
VALA_EXTERN void main_window_structure_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_main_window_structure (const gchar* name,
                                              const gchar* nick,
                                              const gchar* blurb,
                                              GType object_type,
                                              GParamFlags flags);
VALA_EXTERN void value_set_main_window_structure (GValue* value,
                                      gpointer v_object);
VALA_EXTERN void value_take_main_window_structure (GValue* value,
                                       gpointer v_object);
VALA_EXTERN gpointer value_get_main_window_structure (const GValue* value);
VALA_EXTERN GType main_window_structure_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MainWindowStructure, main_window_structure_unref)
VALA_EXTERN GType structure_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Structure, g_object_unref)
VALA_EXTERN void main_window_structure_on_cut (MainWindowStructure* self);
static void _main_window_structure_on_cut_gcallback (GtkAction* action,
                                              gpointer self);
VALA_EXTERN void main_window_structure_on_copy (MainWindowStructure* self);
static void _main_window_structure_on_copy_gcallback (GtkAction* action,
                                               gpointer self);
VALA_EXTERN void main_window_structure_on_delete (MainWindowStructure* self);
static void _main_window_structure_on_delete_gcallback (GtkAction* action,
                                                 gpointer self);
VALA_EXTERN void main_window_structure_on_select (MainWindowStructure* self);
static void _main_window_structure_on_select_gcallback (GtkAction* action,
                                                 gpointer self);
VALA_EXTERN void main_window_structure_on_comment (MainWindowStructure* self);
static void _main_window_structure_on_comment_gcallback (GtkAction* action,
                                                  gpointer self);
VALA_EXTERN void main_window_structure_on_shift_left (MainWindowStructure* self);
static void _main_window_structure_on_shift_left_gcallback (GtkAction* action,
                                                     gpointer self);
VALA_EXTERN void main_window_structure_on_shift_right (MainWindowStructure* self);
static void _main_window_structure_on_shift_right_gcallback (GtkAction* action,
                                                      gpointer self);
VALA_EXTERN void main_window_structure_on_open_file (MainWindowStructure* self);
static void _main_window_structure_on_open_file_gcallback (GtkAction* action,
                                                    gpointer self);
VALA_EXTERN MainWindowStructure* main_window_structure_new (GtkUIManager* ui_manager);
VALA_EXTERN MainWindowStructure* main_window_structure_construct (GType object_type,
                                                      GtkUIManager* ui_manager);
VALA_EXTERN void main_window_structure_set_structure (MainWindowStructure* self,
                                          Structure* structure);
static void main_window_structure_show_popup_menu (MainWindowStructure* self,
                                            GdkEventButton* event);
static void _main_window_structure_show_popup_menu_structure_show_popup_menu (Structure* _sender,
                                                                       GdkEventButton* event,
                                                                       gpointer self);
static void main_window_structure_set_menu_insensitive (MainWindowStructure* self);
static void _main_window_structure_set_menu_insensitive_gtk_widget_hide (GtkWidget* _sender,
                                                                  gpointer self);
static void _main_window_structure_set_menu_insensitive_structure_no_items_selected (Structure* _sender,
                                                                              gpointer self);
VALA_EXTERN GType struct_type_get_type (void) G_GNUC_CONST ;
static void main_window_structure_set_actions_sensitivity (MainWindowStructure* self,
                                                    StructType type);
static void _main_window_structure_set_actions_sensitivity_structure_item_selected (Structure* _sender,
                                                                             StructType type,
                                                                             gpointer self);
VALA_EXTERN void main_window_structure_save_state (MainWindowStructure* self);
VALA_EXTERN void structure_save_state (Structure* self);
VALA_EXTERN void main_window_structure_refresh (MainWindowStructure* self);
VALA_EXTERN void structure_refresh (Structure* self);
VALA_EXTERN GType struct_action_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void structure_do_action (Structure* self,
                          StructAction action_type);
static void main_window_structure_finalize (MainWindowStructure * obj);
static GType main_window_structure_get_type_once (void);

static const GtkActionEntry MAIN_WINDOW_STRUCTURE__action_entries[9] = {{"Structure", NULL, N_ ("S_tructure")}, {"StructureCut", "edit-cut", N_ ("Cu_t"), "", N_ ("Cut the selected structure item"), (GCallback) _main_window_structure_on_cut_gcallback}, {"StructureCopy", "edit-copy", N_ ("_Copy"), "", N_ ("Copy the selected structure item"), (GCallback) _main_window_structure_on_copy_gcallback}, {"StructureDelete", "edit-delete", N_ ("_Delete"), "", N_ ("Delete the selected structure item"), (GCallback) _main_window_structure_on_delete_gcallback}, {"StructureSelect", "edit-select-all", N_ ("_Select"), "", N_ ("Select the contents of the selected structure item"), (GCallback) _main_window_structure_on_select_gcallback}, {"StructureComment", NULL, N_ ("_Comment"), NULL, N_ ("Comment the selected structure item"), (GCallback) _main_window_structure_on_comment_gcallback}, {"StructureShiftLeft", "go-previous", N_ ("Shift _Left"), "", N_ ("Shift the selected structure item to the left (e.g. section → chapter)"), (GCallback) _main_window_structure_on_shift_left_gcallback}, {"StructureShiftRight", "go-next", N_ ("Shift _Right"), "", N_ ("Shift the selected structure item to the right (e.g. chapter → section" \
")"), (GCallback) _main_window_structure_on_shift_right_gcallback}, {"StructureOpenFile", "document-open", N_ ("_Open File"), "", N_ ("Open the file referenced by the selected structure item"), (GCallback) _main_window_structure_on_open_file_gcallback}};

static inline gpointer
main_window_structure_get_instance_private (MainWindowStructure* self)
{
	return G_STRUCT_MEMBER_P (self, MainWindowStructure_private_offset);
}

static void
_main_window_structure_on_cut_gcallback (GtkAction* action,
                                         gpointer self)
{
	main_window_structure_on_cut ((MainWindowStructure*) self);
}

static void
_main_window_structure_on_copy_gcallback (GtkAction* action,
                                          gpointer self)
{
	main_window_structure_on_copy ((MainWindowStructure*) self);
}

static void
_main_window_structure_on_delete_gcallback (GtkAction* action,
                                            gpointer self)
{
	main_window_structure_on_delete ((MainWindowStructure*) self);
}

static void
_main_window_structure_on_select_gcallback (GtkAction* action,
                                            gpointer self)
{
	main_window_structure_on_select ((MainWindowStructure*) self);
}

static void
_main_window_structure_on_comment_gcallback (GtkAction* action,
                                             gpointer self)
{
	main_window_structure_on_comment ((MainWindowStructure*) self);
}

static void
_main_window_structure_on_shift_left_gcallback (GtkAction* action,
                                                gpointer self)
{
	main_window_structure_on_shift_left ((MainWindowStructure*) self);
}

static void
_main_window_structure_on_shift_right_gcallback (GtkAction* action,
                                                 gpointer self)
{
	main_window_structure_on_shift_right ((MainWindowStructure*) self);
}

static void
_main_window_structure_on_open_file_gcallback (GtkAction* action,
                                               gpointer self)
{
	main_window_structure_on_open_file ((MainWindowStructure*) self);
}

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

MainWindowStructure*
main_window_structure_construct (GType object_type,
                                 GtkUIManager* ui_manager)
{
	MainWindowStructure* self = NULL;
	GtkUIManager* _tmp0_;
	GtkActionGroup* action_group = NULL;
	GtkActionGroup* _tmp1_;
	g_return_val_if_fail (ui_manager != NULL, NULL);
	self = (MainWindowStructure*) g_type_create_instance (object_type);
	_tmp0_ = _g_object_ref0 (ui_manager);
	_g_object_unref0 (self->priv->_ui_manager);
	self->priv->_ui_manager = _tmp0_;
	_tmp1_ = gtk_action_group_new ("StructureActionGroup");
	action_group = _tmp1_;
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (action_group, MAIN_WINDOW_STRUCTURE__action_entries, (guint) G_N_ELEMENTS (MAIN_WINDOW_STRUCTURE__action_entries), self);
	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
	_g_object_unref0 (action_group);
	return self;
}

MainWindowStructure*
main_window_structure_new (GtkUIManager* ui_manager)
{
	return main_window_structure_construct (TYPE_MAIN_WINDOW_STRUCTURE, ui_manager);
}

static void
_main_window_structure_show_popup_menu_structure_show_popup_menu (Structure* _sender,
                                                                  GdkEventButton* event,
                                                                  gpointer self)
{
	main_window_structure_show_popup_menu ((MainWindowStructure*) self, event);
}

static void
_main_window_structure_set_menu_insensitive_gtk_widget_hide (GtkWidget* _sender,
                                                             gpointer self)
{
	main_window_structure_set_menu_insensitive ((MainWindowStructure*) self);
}

static void
_main_window_structure_set_menu_insensitive_structure_no_items_selected (Structure* _sender,
                                                                         gpointer self)
{
	main_window_structure_set_menu_insensitive ((MainWindowStructure*) self);
}

static void
_main_window_structure_set_actions_sensitivity_structure_item_selected (Structure* _sender,
                                                                        StructType type,
                                                                        gpointer self)
{
	main_window_structure_set_actions_sensitivity ((MainWindowStructure*) self, type);
}

void
main_window_structure_set_structure (MainWindowStructure* self,
                                     Structure* structure)
{
	Structure* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (structure != NULL);
	_tmp0_ = _g_object_ref0 (structure);
	_g_object_unref0 (self->priv->_structure);
	self->priv->_structure = _tmp0_;
	g_signal_connect (structure, "show-popup-menu", (GCallback) _main_window_structure_show_popup_menu_structure_show_popup_menu, self);
	g_signal_connect ((GtkWidget*) structure, "hide", (GCallback) _main_window_structure_set_menu_insensitive_gtk_widget_hide, self);
	g_signal_connect (structure, "no-items-selected", (GCallback) _main_window_structure_set_menu_insensitive_structure_no_items_selected, self);
	g_signal_connect (structure, "item-selected", (GCallback) _main_window_structure_set_actions_sensitivity_structure_item_selected, self);
}

void
main_window_structure_save_state (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_save_state (_tmp1_);
}

void
main_window_structure_refresh (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_refresh (_tmp1_);
}

static void
main_window_structure_show_popup_menu (MainWindowStructure* self,
                                       GdkEventButton* event)
{
	GtkMenu* popup_menu = NULL;
	GtkUIManager* _tmp0_;
	GtkWidget* _tmp1_;
	GtkMenu* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_ui_manager;
	_tmp1_ = gtk_ui_manager_get_widget (_tmp0_, "/StructurePopup");
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, gtk_menu_get_type ()) ? ((GtkMenu*) _tmp1_) : NULL);
	popup_menu = _tmp2_;
	gtk_menu_popup_at_pointer (popup_menu, (GdkEvent*) event);
	_g_object_unref0 (popup_menu);
}

static void
main_window_structure_set_menu_insensitive (MainWindowStructure* self)
{
	GtkUIManager* _tmp0_;
	GtkAction* menu = NULL;
	GtkUIManager* _tmp1_;
	GtkAction* _tmp2_;
	GtkAction* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_ui_manager;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_ui_manager;
	_tmp2_ = gtk_ui_manager_get_action (_tmp1_, "/MainMenu/Structure");
	_tmp3_ = _g_object_ref0 (_tmp2_);
	menu = _tmp3_;
	gtk_action_set_sensitive (menu, FALSE);
	_g_object_unref0 (menu);
}

static void
main_window_structure_set_actions_sensitivity (MainWindowStructure* self,
                                               StructType type)
{
	GtkAction* menu = NULL;
	GtkUIManager* _tmp0_;
	GtkAction* _tmp1_;
	GtkAction* _tmp2_;
	GtkAction* _tmp3_;
	GtkAction* shift_left = NULL;
	GtkUIManager* _tmp4_;
	GtkAction* _tmp5_;
	GtkAction* _tmp6_;
	gboolean _tmp7_ = FALSE;
	GtkAction* _tmp8_;
	GtkAction* shift_right = NULL;
	GtkUIManager* _tmp9_;
	GtkAction* _tmp10_;
	GtkAction* _tmp11_;
	gboolean _tmp12_ = FALSE;
	GtkAction* _tmp13_;
	GtkAction* open_file = NULL;
	GtkUIManager* _tmp14_;
	GtkAction* _tmp15_;
	GtkAction* _tmp16_;
	gboolean _tmp17_ = FALSE;
	GtkAction* _tmp18_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_ui_manager;
	_tmp1_ = gtk_ui_manager_get_action (_tmp0_, "/MainMenu/Structure");
	_tmp2_ = _g_object_ref0 (_tmp1_);
	menu = _tmp2_;
	_tmp3_ = menu;
	gtk_action_set_sensitive (_tmp3_, TRUE);
	_tmp4_ = self->priv->_ui_manager;
	_tmp5_ = gtk_ui_manager_get_action (_tmp4_, "/StructurePopup/StructureShiftLeft");
	_tmp6_ = _g_object_ref0 (_tmp5_);
	shift_left = _tmp6_;
	if (STRUCT_TYPE_PART < type) {
		_tmp7_ = type <= STRUCT_TYPE_SUBPARAGRAPH;
	} else {
		_tmp7_ = FALSE;
	}
	_tmp8_ = shift_left;
	gtk_action_set_sensitive (_tmp8_, _tmp7_);
	_tmp9_ = self->priv->_ui_manager;
	_tmp10_ = gtk_ui_manager_get_action (_tmp9_, "/StructurePopup/StructureShiftRight");
	_tmp11_ = _g_object_ref0 (_tmp10_);
	shift_right = _tmp11_;
	if (STRUCT_TYPE_PART <= type) {
		_tmp12_ = type < STRUCT_TYPE_SUBPARAGRAPH;
	} else {
		_tmp12_ = FALSE;
	}
	_tmp13_ = shift_right;
	gtk_action_set_sensitive (_tmp13_, _tmp12_);
	_tmp14_ = self->priv->_ui_manager;
	_tmp15_ = gtk_ui_manager_get_action (_tmp14_, "/StructurePopup/StructureOpenFile");
	_tmp16_ = _g_object_ref0 (_tmp15_);
	open_file = _tmp16_;
	if (type == STRUCT_TYPE_INCLUDE) {
		_tmp17_ = TRUE;
	} else {
		_tmp17_ = type == STRUCT_TYPE_IMAGE;
	}
	_tmp18_ = open_file;
	gtk_action_set_sensitive (_tmp18_, _tmp17_);
	_g_object_unref0 (open_file);
	_g_object_unref0 (shift_right);
	_g_object_unref0 (shift_left);
	_g_object_unref0 (menu);
}

void
main_window_structure_on_cut (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_do_action (_tmp1_, STRUCT_ACTION_CUT);
}

void
main_window_structure_on_copy (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_do_action (_tmp1_, STRUCT_ACTION_COPY);
}

void
main_window_structure_on_delete (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_do_action (_tmp1_, STRUCT_ACTION_DELETE);
}

void
main_window_structure_on_select (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_do_action (_tmp1_, STRUCT_ACTION_SELECT);
}

void
main_window_structure_on_comment (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_do_action (_tmp1_, STRUCT_ACTION_COMMENT);
}

void
main_window_structure_on_shift_left (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_do_action (_tmp1_, STRUCT_ACTION_SHIFT_LEFT);
}

void
main_window_structure_on_shift_right (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_do_action (_tmp1_, STRUCT_ACTION_SHIFT_RIGHT);
}

void
main_window_structure_on_open_file (MainWindowStructure* self)
{
	Structure* _tmp0_;
	Structure* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structure;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->_structure;
	structure_do_action (_tmp1_, STRUCT_ACTION_OPEN_FILE);
}

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

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

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

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

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

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

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

void
value_set_main_window_structure (GValue* value,
                                 gpointer v_object)
{
	MainWindowStructure * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_STRUCTURE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_WINDOW_STRUCTURE));
		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;
		main_window_structure_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		main_window_structure_unref (old);
	}
}

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

static void
main_window_structure_class_init (MainWindowStructureClass * klass,
                                  gpointer klass_data)
{
	main_window_structure_parent_class = g_type_class_peek_parent (klass);
	((MainWindowStructureClass *) klass)->finalize = main_window_structure_finalize;
	g_type_class_adjust_private_offset (klass, &MainWindowStructure_private_offset);
}

static void
main_window_structure_instance_init (MainWindowStructure * self,
                                     gpointer klass)
{
	self->priv = main_window_structure_get_instance_private (self);
	self->ref_count = 1;
}

static void
main_window_structure_finalize (MainWindowStructure * obj)
{
	MainWindowStructure * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MAIN_WINDOW_STRUCTURE, MainWindowStructure);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->_ui_manager);
	_g_object_unref0 (self->priv->_structure);
}

 G_GNUC_NO_INLINE static GType
main_window_structure_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_main_window_structure_init, value_main_window_structure_free_value, value_main_window_structure_copy_value, value_main_window_structure_peek_pointer, "p", value_main_window_structure_collect_value, "p", value_main_window_structure_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (MainWindowStructureClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) main_window_structure_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MainWindowStructure), 0, (GInstanceInitFunc) main_window_structure_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 main_window_structure_type_id;
	main_window_structure_type_id = g_type_register_fundamental (g_type_fundamental_next (), "MainWindowStructure", &g_define_type_info, &g_define_type_fundamental_info, 0);
	MainWindowStructure_private_offset = g_type_add_instance_private (main_window_structure_type_id, sizeof (MainWindowStructurePrivate));
	return main_window_structure_type_id;
}

GType
main_window_structure_get_type (void)
{
	static gsize main_window_structure_type_id__once = 0;
	if (g_once_init_enter (&main_window_structure_type_id__once)) {
		GType main_window_structure_type_id;
		main_window_structure_type_id = main_window_structure_get_type_once ();
		g_once_init_leave (&main_window_structure_type_id__once, main_window_structure_type_id);
	}
	return main_window_structure_type_id__once;
}

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

void
main_window_structure_unref (gpointer instance)
{
	MainWindowStructure * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		MAIN_WINDOW_STRUCTURE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

