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

/*
* Copyright (c) 2024-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 <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <granite-7.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>
#include <string.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_IMAGE_MENU (image_menu_get_type ())
#define IMAGE_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IMAGE_MENU, ImageMenu))
#define IMAGE_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_IMAGE_MENU, ImageMenuClass))
#define IS_IMAGE_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IMAGE_MENU))
#define IS_IMAGE_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_IMAGE_MENU))
#define IMAGE_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_IMAGE_MENU, ImageMenuClass))

typedef struct _ImageMenu ImageMenu;
typedef struct _ImageMenuClass ImageMenuClass;
typedef struct _ImageMenuPrivate ImageMenuPrivate;
enum  {
	IMAGE_MENU_0_PROPERTY,
	IMAGE_MENU_SELECTED_PROPERTY,
	IMAGE_MENU_NUM_PROPERTIES
};
static GParamSpec* image_menu_properties[IMAGE_MENU_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block27Data Block27Data;
enum  {
	IMAGE_MENU_CHANGED_SIGNAL,
	IMAGE_MENU_UPDATE_ICONS_SIGNAL,
	IMAGE_MENU_EDITABLE_CHANGED_SIGNAL,
	IMAGE_MENU_NUM_SIGNALS
};
static guint image_menu_signals[IMAGE_MENU_NUM_SIGNALS] = {0};

struct _ImageMenu {
	GtkBox parent_instance;
	ImageMenuPrivate * priv;
};

struct _ImageMenuClass {
	GtkBoxClass parent_class;
};

struct _ImageMenuPrivate {
	GtkMenuButton* _mb;
	GtkBox* _box;
	gint _size;
	gint _selected;
	gint _current;
};

struct _Block27Data {
	int _ref_count_;
	ImageMenu* self;
	GtkPicture* entry;
	gint index;
	GdkPaintable* light_image;
	GdkPaintable* dark_image;
};

static gint ImageMenu_private_offset;
static gpointer image_menu_parent_class = NULL;

VALA_EXTERN GType image_menu_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ImageMenu, g_object_unref)
VALA_EXTERN ImageMenu* image_menu_new (void);
VALA_EXTERN ImageMenu* image_menu_construct (GType object_type);
static void __lambda197_ (ImageMenu* self);
VALA_EXTERN GtkWidget* utils_get_child_at_index (GtkWidget* parent,
                                     gint index);
static void ___lambda197__gtk_menu_button_activate (GtkMenuButton* _sender,
                                             gpointer self);
static void __lambda198_ (ImageMenu* self,
                   gboolean editable);
static void ___lambda198__image_menu_editable_changed (ImageMenu* _sender,
                                                gboolean editable,
                                                gpointer self);
static gboolean __lambda199_ (ImageMenu* self,
                       guint keyval,
                       guint keycode,
                       GdkModifierType state);
VALA_EXTERN void image_menu_set_selected (ImageMenu* self,
                              gint value);
static gboolean ___lambda199__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                             guint keyval,
                                                             guint keycode,
                                                             GdkModifierType state,
                                                             gpointer self);
VALA_EXTERN void image_menu_add_image (ImageMenu* self,
                           GdkPaintable* light_image,
                           GdkPaintable* dark_image);
static Block27Data* block27_data_ref (Block27Data* _data27_);
static void block27_data_unref (void * _userdata_);
static void __lambda200_ (Block27Data* _data27_);
VALA_EXTERN gboolean utils_use_dark_mode (GtkWidget* w);
VALA_EXTERN gint image_menu_get_selected (ImageMenu* self);
static void ___lambda200__image_menu_update_icons (ImageMenu* _sender,
                                            gpointer self);
static void __lambda201_ (Block27Data* _data27_,
                   gint n_press,
                   gdouble x,
                   gdouble y);
static void ___lambda201__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self);
static void __lambda202_ (Block27Data* _data27_);
static void ___lambda202__gtk_event_controller_motion_enter (GtkEventControllerMotion* _sender,
                                                      gdouble x,
                                                      gdouble y,
                                                      gpointer self);
static void __lambda203_ (Block27Data* _data27_);
static void ___lambda203__gtk_event_controller_motion_leave (GtkEventControllerMotion* _sender,
                                                      gpointer self);
static void image_menu_finalize (GObject * obj);
static GType image_menu_get_type_once (void);
static void _vala_image_menu_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec);
static void _vala_image_menu_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
image_menu_get_instance_private (ImageMenu* self)
{
	return G_STRUCT_MEMBER_P (self, ImageMenu_private_offset);
}

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

static void
__lambda197_ (ImageMenu* self)
{
	GtkPicture* picture = NULL;
	GtkBox* _tmp0_;
	GtkWidget* _tmp1_;
	_tmp0_ = self->priv->_box;
	_tmp1_ = utils_get_child_at_index ((GtkWidget*) _tmp0_, 0);
	picture = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_picture_get_type (), GtkPicture);
	self->priv->_current = 0;
	gtk_widget_add_css_class ((GtkWidget*) picture, GRANITE_STYLE_CLASS_VIEW);
	_g_object_unref0 (picture);
}

static void
___lambda197__gtk_menu_button_activate (GtkMenuButton* _sender,
                                        gpointer self)
{
	__lambda197_ ((ImageMenu*) self);
}

static void
__lambda198_ (ImageMenu* self,
              gboolean editable)
{
	GtkMenuButton* _tmp0_;
	_tmp0_ = self->priv->_mb;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, editable);
}

static void
___lambda198__image_menu_editable_changed (ImageMenu* _sender,
                                           gboolean editable,
                                           gpointer self)
{
	__lambda198_ ((ImageMenu*) self, editable);
}

static gboolean
__lambda199_ (ImageMenu* self,
              guint keyval,
              guint keycode,
              GdkModifierType state)
{
	gint index = 0;
	GtkPicture* before = NULL;
	GtkBox* _tmp8_;
	GtkWidget* _tmp9_;
	GtkPicture* _tmp10_;
	gboolean result;
	index = self->priv->_current;
	switch (keyval) {
		case GDK_KEY_Down:
		{
			gint _tmp0_ = 0;
			if (self->priv->_current == (self->priv->_size - 1)) {
				_tmp0_ = self->priv->_current;
			} else {
				_tmp0_ = self->priv->_current + 1;
			}
			index = _tmp0_;
			break;
		}
		case GDK_KEY_Up:
		{
			gint _tmp1_ = 0;
			if (self->priv->_current == 0) {
				_tmp1_ = self->priv->_current;
			} else {
				_tmp1_ = self->priv->_current - 1;
			}
			index = _tmp1_;
			break;
		}
		case GDK_KEY_Return:
		case GDK_KEY_space:
		{
			GtkMenuButton* _tmp2_;
			GtkPopover* _tmp3_;
			GtkPopover* _tmp4_;
			image_menu_set_selected (self, self->priv->_current);
			g_signal_emit (self, image_menu_signals[IMAGE_MENU_CHANGED_SIGNAL], 0, self->priv->_current);
			_tmp2_ = self->priv->_mb;
			_tmp3_ = gtk_menu_button_get_popover (_tmp2_);
			_tmp4_ = _tmp3_;
			gtk_popover_popdown (_tmp4_);
			break;
		}
		case GDK_KEY_Escape:
		{
			GtkMenuButton* _tmp5_;
			GtkPopover* _tmp6_;
			GtkPopover* _tmp7_;
			_tmp5_ = self->priv->_mb;
			_tmp6_ = gtk_menu_button_get_popover (_tmp5_);
			_tmp7_ = _tmp6_;
			gtk_popover_popdown (_tmp7_);
			break;
		}
		default:
		break;
	}
	_tmp8_ = self->priv->_box;
	_tmp9_ = utils_get_child_at_index ((GtkWidget*) _tmp8_, self->priv->_current);
	before = G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_picture_get_type (), GtkPicture);
	_tmp10_ = before;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp10_, GRANITE_STYLE_CLASS_VIEW);
	if (index != self->priv->_current) {
		GtkPicture* after = NULL;
		GtkBox* _tmp11_;
		GtkWidget* _tmp12_;
		GtkPicture* _tmp13_;
		_tmp11_ = self->priv->_box;
		_tmp12_ = utils_get_child_at_index ((GtkWidget*) _tmp11_, index);
		after = G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_picture_get_type (), GtkPicture);
		_tmp13_ = after;
		gtk_widget_add_css_class ((GtkWidget*) _tmp13_, GRANITE_STYLE_CLASS_VIEW);
		_g_object_unref0 (after);
	}
	result = FALSE;
	_g_object_unref0 (before);
	return result;
}

static gboolean
___lambda199__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                    guint keyval,
                                                    guint keycode,
                                                    GdkModifierType state,
                                                    gpointer self)
{
	gboolean result;
	result = __lambda199_ ((ImageMenu*) self, keyval, keycode, state);
	return result;
}

ImageMenu*
image_menu_construct (GType object_type)
{
	ImageMenu * self = NULL;
	GtkBox* _tmp0_ = NULL;
	GtkPopover* popover = NULL;
	GtkBox* _tmp1_;
	GtkWidget* _tmp2_;
	GtkPopover* _tmp3_ = NULL;
	GtkPopover* _tmp4_;
	GtkMenuButton* _tmp5_ = NULL;
	GtkMenuButton* _tmp6_;
	GtkEventControllerKey* key = NULL;
	GtkEventControllerKey* _tmp7_;
	GtkMenuButton* _tmp8_;
	GtkEventController* _tmp9_;
	GtkMenuButton* _tmp10_;
	self = (ImageMenu*) g_object_new (object_type, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp0_, 5);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp0_, 5);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->_box);
	self->priv->_box = _tmp0_;
	_tmp1_ = self->priv->_box;
	_tmp2_ = _g_object_ref0 ((GtkWidget*) _tmp1_);
	_tmp3_ = (GtkPopover*) gtk_popover_new ();
	gtk_popover_set_child (_tmp3_, _tmp2_);
	_g_object_unref0 (_tmp2_);
	g_object_ref_sink (_tmp3_);
	popover = _tmp3_;
	_tmp4_ = _g_object_ref0 (popover);
	_tmp5_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_widget_set_valign ((GtkWidget*) _tmp5_, GTK_ALIGN_CENTER);
	gtk_menu_button_set_popover (_tmp5_, _tmp4_);
	_g_object_unref0 (_tmp4_);
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->_mb);
	self->priv->_mb = _tmp5_;
	_tmp6_ = self->priv->_mb;
	g_signal_connect_object (_tmp6_, "activate", (GCallback) ___lambda197__gtk_menu_button_activate, self, 0);
	g_signal_connect_object (self, "editable-changed", (GCallback) ___lambda198__image_menu_editable_changed, self, 0);
	_tmp7_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	key = _tmp7_;
	_tmp8_ = self->priv->_mb;
	_tmp9_ = _g_object_ref0 ((GtkEventController*) key);
	gtk_widget_add_controller ((GtkWidget*) _tmp8_, _tmp9_);
	g_signal_connect_object (key, "key-pressed", (GCallback) ___lambda199__gtk_event_controller_key_key_pressed, self, 0);
	_tmp10_ = self->priv->_mb;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp10_);
	_g_object_unref0 (key);
	_g_object_unref0 (popover);
	return self;
}

ImageMenu*
image_menu_new (void)
{
	return image_menu_construct (TYPE_IMAGE_MENU);
}

static Block27Data*
block27_data_ref (Block27Data* _data27_)
{
	g_atomic_int_inc (&_data27_->_ref_count_);
	return _data27_;
}

static void
block27_data_unref (void * _userdata_)
{
	Block27Data* _data27_;
	_data27_ = (Block27Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data27_->_ref_count_)) {
		ImageMenu* self;
		self = _data27_->self;
		_g_object_unref0 (_data27_->entry);
		_g_object_unref0 (_data27_->light_image);
		_g_object_unref0 (_data27_->dark_image);
		_g_object_unref0 (self);
		g_slice_free (Block27Data, _data27_);
	}
}

static void
__lambda200_ (Block27Data* _data27_)
{
	ImageMenu* self;
	GdkPaintable* _tmp0_ = NULL;
	gint _tmp1_;
	gint _tmp2_;
	self = _data27_->self;
	if (utils_use_dark_mode ((GtkWidget*) self)) {
		_tmp0_ = _data27_->dark_image;
	} else {
		_tmp0_ = _data27_->light_image;
	}
	gtk_picture_set_paintable (_data27_->entry, _tmp0_);
	_tmp1_ = image_menu_get_selected (self);
	_tmp2_ = _tmp1_;
	if (_data27_->index == _tmp2_) {
		GtkMenuButton* _tmp3_;
		GdkPaintable* _tmp4_;
		GdkPaintable* _tmp5_;
		GtkPicture* _tmp6_;
		GtkPicture* _tmp7_;
		_tmp3_ = self->priv->_mb;
		_tmp4_ = gtk_picture_get_paintable (_data27_->entry);
		_tmp5_ = _tmp4_;
		_tmp6_ = (GtkPicture*) gtk_picture_new_for_paintable (_tmp5_);
		g_object_ref_sink (_tmp6_);
		_tmp7_ = _tmp6_;
		gtk_menu_button_set_child (_tmp3_, (GtkWidget*) _tmp7_);
		_g_object_unref0 (_tmp7_);
	}
}

static void
___lambda200__image_menu_update_icons (ImageMenu* _sender,
                                       gpointer self)
{
	__lambda200_ (self);
}

static void
__lambda201_ (Block27Data* _data27_,
              gint n_press,
              gdouble x,
              gdouble y)
{
	ImageMenu* self;
	GtkMenuButton* _tmp0_;
	GtkPopover* _tmp1_;
	GtkPopover* _tmp2_;
	self = _data27_->self;
	image_menu_set_selected (self, _data27_->index);
	_tmp0_ = self->priv->_mb;
	_tmp1_ = gtk_menu_button_get_popover (_tmp0_);
	_tmp2_ = _tmp1_;
	gtk_popover_popdown (_tmp2_);
	g_signal_emit (self, image_menu_signals[IMAGE_MENU_CHANGED_SIGNAL], 0, _data27_->index);
}

static void
___lambda201__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                         gint n_press,
                                         gdouble x,
                                         gdouble y,
                                         gpointer self)
{
	__lambda201_ (self, n_press, x, y);
}

static void
__lambda202_ (Block27Data* _data27_)
{
	ImageMenu* self;
	self = _data27_->self;
	gtk_widget_add_css_class ((GtkWidget*) _data27_->entry, GRANITE_STYLE_CLASS_VIEW);
}

static void
___lambda202__gtk_event_controller_motion_enter (GtkEventControllerMotion* _sender,
                                                 gdouble x,
                                                 gdouble y,
                                                 gpointer self)
{
	__lambda202_ (self);
}

static void
__lambda203_ (Block27Data* _data27_)
{
	ImageMenu* self;
	self = _data27_->self;
	gtk_widget_remove_css_class ((GtkWidget*) _data27_->entry, GRANITE_STYLE_CLASS_VIEW);
}

static void
___lambda203__gtk_event_controller_motion_leave (GtkEventControllerMotion* _sender,
                                                 gpointer self)
{
	__lambda203_ (self);
}

void
image_menu_add_image (ImageMenu* self,
                      GdkPaintable* light_image,
                      GdkPaintable* dark_image)
{
	Block27Data* _data27_;
	GdkPaintable* _tmp0_;
	GdkPaintable* _tmp1_;
	GtkPicture* _tmp2_;
	gint _tmp3_;
	GtkGestureClick* click = NULL;
	GtkGestureClick* _tmp4_;
	GtkEventController* _tmp5_;
	GtkEventControllerMotion* motion = NULL;
	GtkEventControllerMotion* _tmp6_;
	GtkEventController* _tmp7_;
	GtkBox* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (light_image != NULL);
	g_return_if_fail (dark_image != NULL);
	_data27_ = g_slice_new0 (Block27Data);
	_data27_->_ref_count_ = 1;
	_data27_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (light_image);
	_g_object_unref0 (_data27_->light_image);
	_data27_->light_image = _tmp0_;
	_tmp1_ = _g_object_ref0 (dark_image);
	_g_object_unref0 (_data27_->dark_image);
	_data27_->dark_image = _tmp1_;
	_tmp2_ = (GtkPicture*) gtk_picture_new_for_paintable (_data27_->light_image);
	g_object_ref_sink (_tmp2_);
	_data27_->entry = _tmp2_;
	_tmp3_ = self->priv->_size;
	self->priv->_size = _tmp3_ + 1;
	_data27_->index = _tmp3_;
	g_signal_connect_data (self, "update-icons", (GCallback) ___lambda200__image_menu_update_icons, block27_data_ref (_data27_), (GClosureNotify) block27_data_unref, 0);
	_tmp4_ = (GtkGestureClick*) gtk_gesture_click_new ();
	click = _tmp4_;
	_tmp5_ = _g_object_ref0 ((GtkEventController*) click);
	gtk_widget_add_controller ((GtkWidget*) _data27_->entry, _tmp5_);
	g_signal_connect_data (click, "pressed", (GCallback) ___lambda201__gtk_gesture_click_pressed, block27_data_ref (_data27_), (GClosureNotify) block27_data_unref, 0);
	_tmp6_ = (GtkEventControllerMotion*) gtk_event_controller_motion_new ();
	motion = _tmp6_;
	_tmp7_ = _g_object_ref0 ((GtkEventController*) motion);
	gtk_widget_add_controller ((GtkWidget*) _data27_->entry, _tmp7_);
	g_signal_connect_data (motion, "enter", (GCallback) ___lambda202__gtk_event_controller_motion_enter, block27_data_ref (_data27_), (GClosureNotify) block27_data_unref, 0);
	g_signal_connect_data (motion, "leave", (GCallback) ___lambda203__gtk_event_controller_motion_leave, block27_data_ref (_data27_), (GClosureNotify) block27_data_unref, 0);
	_tmp8_ = self->priv->_box;
	gtk_box_append (_tmp8_, (GtkWidget*) _data27_->entry);
	_g_object_unref0 (motion);
	_g_object_unref0 (click);
	block27_data_unref (_data27_);
	_data27_ = NULL;
}

gint
image_menu_get_selected (ImageMenu* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_selected;
	return result;
}

void
image_menu_set_selected (ImageMenu* self,
                         gint value)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_selected != value) {
		GtkPicture* picture = NULL;
		GtkBox* _tmp0_;
		GtkWidget* _tmp1_;
		GtkMenuButton* _tmp2_;
		GtkPicture* _tmp3_;
		GdkPaintable* _tmp4_;
		GdkPaintable* _tmp5_;
		GtkPicture* _tmp6_;
		GtkPicture* _tmp7_;
		self->priv->_selected = value;
		_tmp0_ = self->priv->_box;
		_tmp1_ = utils_get_child_at_index ((GtkWidget*) _tmp0_, self->priv->_selected);
		picture = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_picture_get_type (), GtkPicture);
		_tmp2_ = self->priv->_mb;
		_tmp3_ = picture;
		_tmp4_ = gtk_picture_get_paintable (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = (GtkPicture*) gtk_picture_new_for_paintable (_tmp5_);
		g_object_ref_sink (_tmp6_);
		_tmp7_ = _tmp6_;
		gtk_menu_button_set_child (_tmp2_, (GtkWidget*) _tmp7_);
		_g_object_unref0 (_tmp7_);
		_g_object_unref0 (picture);
	}
	g_object_notify_by_pspec ((GObject *) self, image_menu_properties[IMAGE_MENU_SELECTED_PROPERTY]);
}

static void
image_menu_class_init (ImageMenuClass * klass,
                       gpointer klass_data)
{
	image_menu_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ImageMenu_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_image_menu_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_image_menu_set_property;
	G_OBJECT_CLASS (klass)->finalize = image_menu_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), IMAGE_MENU_SELECTED_PROPERTY, image_menu_properties[IMAGE_MENU_SELECTED_PROPERTY] = g_param_spec_int ("selected", "selected", "selected", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	image_menu_signals[IMAGE_MENU_CHANGED_SIGNAL] = g_signal_new ("changed", TYPE_IMAGE_MENU, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
	image_menu_signals[IMAGE_MENU_UPDATE_ICONS_SIGNAL] = g_signal_new ("update-icons", TYPE_IMAGE_MENU, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	image_menu_signals[IMAGE_MENU_EDITABLE_CHANGED_SIGNAL] = g_signal_new ("editable-changed", TYPE_IMAGE_MENU, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
image_menu_instance_init (ImageMenu * self,
                          gpointer klass)
{
	self->priv = image_menu_get_instance_private (self);
	self->priv->_size = 0;
	self->priv->_selected = -1;
	self->priv->_current = 0;
}

static void
image_menu_finalize (GObject * obj)
{
	ImageMenu * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_IMAGE_MENU, ImageMenu);
	_g_object_unref0 (self->priv->_mb);
	_g_object_unref0 (self->priv->_box);
	G_OBJECT_CLASS (image_menu_parent_class)->finalize (obj);
}

static GType
image_menu_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ImageMenuClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) image_menu_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ImageMenu), 0, (GInstanceInitFunc) image_menu_instance_init, NULL };
	GType image_menu_type_id;
	image_menu_type_id = g_type_register_static (gtk_box_get_type (), "ImageMenu", &g_define_type_info, 0);
	ImageMenu_private_offset = g_type_add_instance_private (image_menu_type_id, sizeof (ImageMenuPrivate));
	return image_menu_type_id;
}

GType
image_menu_get_type (void)
{
	static volatile gsize image_menu_type_id__once = 0;
	if (g_once_init_enter (&image_menu_type_id__once)) {
		GType image_menu_type_id;
		image_menu_type_id = image_menu_get_type_once ();
		g_once_init_leave (&image_menu_type_id__once, image_menu_type_id);
	}
	return image_menu_type_id__once;
}

static void
_vala_image_menu_get_property (GObject * object,
                               guint property_id,
                               GValue * value,
                               GParamSpec * pspec)
{
	ImageMenu * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_IMAGE_MENU, ImageMenu);
	switch (property_id) {
		case IMAGE_MENU_SELECTED_PROPERTY:
		g_value_set_int (value, image_menu_get_selected (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_image_menu_set_property (GObject * object,
                               guint property_id,
                               const GValue * value,
                               GParamSpec * pspec)
{
	ImageMenu * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_IMAGE_MENU, ImageMenu);
	switch (property_id) {
		case IMAGE_MENU_SELECTED_PROPERTY:
		image_menu_set_selected (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

