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

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2013 Timm Bäder
 *
 *  corebird 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.
 *
 *  corebird 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 corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>


#define TYPE_LAZY_MENU_BUTTON (lazy_menu_button_get_type ())
#define LAZY_MENU_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LAZY_MENU_BUTTON, LazyMenuButton))
#define LAZY_MENU_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LAZY_MENU_BUTTON, LazyMenuButtonClass))
#define IS_LAZY_MENU_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LAZY_MENU_BUTTON))
#define IS_LAZY_MENU_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LAZY_MENU_BUTTON))
#define LAZY_MENU_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LAZY_MENU_BUTTON, LazyMenuButtonClass))

typedef struct _LazyMenuButton LazyMenuButton;
typedef struct _LazyMenuButtonClass LazyMenuButtonClass;
typedef struct _LazyMenuButtonPrivate LazyMenuButtonPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _LazyMenuButton {
	GtkToggleButton parent_instance;
	LazyMenuButtonPrivate * priv;
};

struct _LazyMenuButtonClass {
	GtkToggleButtonClass parent_class;
};

struct _LazyMenuButtonPrivate {
	GMenu* _menu_model;
};


static gpointer lazy_menu_button_parent_class = NULL;

GType lazy_menu_button_get_type (void) G_GNUC_CONST;
#define LAZY_MENU_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_LAZY_MENU_BUTTON, LazyMenuButtonPrivate))
enum  {
	LAZY_MENU_BUTTON_DUMMY_PROPERTY,
	LAZY_MENU_BUTTON_MENU_MODEL
};
static void lazy_menu_button_real_clicked (GtkButton* base);
GMenu* lazy_menu_button_get_menu_model (LazyMenuButton* self);
LazyMenuButton* lazy_menu_button_new (void);
LazyMenuButton* lazy_menu_button_construct (GType object_type);
void lazy_menu_button_set_menu_model (LazyMenuButton* self, GMenu* value);
static void lazy_menu_button_finalize (GObject* obj);
static void _vala_lazy_menu_button_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_lazy_menu_button_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void lazy_menu_button_real_clicked (GtkButton* base) {
	LazyMenuButton * self;
	GtkPopover* popover = NULL;
	GMenu* _tmp0_ = NULL;
	GtkPopover* _tmp1_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_LAZY_MENU_BUTTON, LazyMenuButton);
	_tmp0_ = self->priv->_menu_model;
	_tmp1_ = (GtkPopover*) gtk_popover_new_from_model (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, g_menu_model_get_type (), GMenuModel));
	g_object_ref_sink (_tmp1_);
	popover = _tmp1_;
	gtk_popover_set_position (popover, GTK_POS_BOTTOM);
	gtk_widget_show (G_TYPE_CHECK_INSTANCE_CAST (popover, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (popover);
}


LazyMenuButton* lazy_menu_button_construct (GType object_type) {
	LazyMenuButton * self = NULL;
	self = (LazyMenuButton*) g_object_new (object_type, NULL);
	return self;
}


LazyMenuButton* lazy_menu_button_new (void) {
	return lazy_menu_button_construct (TYPE_LAZY_MENU_BUTTON);
}


GMenu* lazy_menu_button_get_menu_model (LazyMenuButton* self) {
	GMenu* result;
	GMenu* _tmp0_ = NULL;
	g_return_val_if_fail (IS_LAZY_MENU_BUTTON (self), NULL);
	_tmp0_ = self->priv->_menu_model;
	result = _tmp0_;
	return result;
}


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


void lazy_menu_button_set_menu_model (LazyMenuButton* self, GMenu* value) {
	GMenu* _tmp0_ = NULL;
	GMenu* _tmp1_ = NULL;
	g_return_if_fail (IS_LAZY_MENU_BUTTON (self));
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_menu_model);
	self->priv->_menu_model = _tmp1_;
	g_object_notify ((GObject *) self, "menu-model");
}


static void lazy_menu_button_class_init (LazyMenuButtonClass * klass) {
	lazy_menu_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (LazyMenuButtonPrivate));
	((GtkButtonClass *) klass)->clicked = lazy_menu_button_real_clicked;
	G_OBJECT_CLASS (klass)->get_property = _vala_lazy_menu_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_lazy_menu_button_set_property;
	G_OBJECT_CLASS (klass)->finalize = lazy_menu_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), LAZY_MENU_BUTTON_MENU_MODEL, g_param_spec_object ("menu-model", "menu-model", "menu-model", g_menu_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void lazy_menu_button_instance_init (LazyMenuButton * self) {
	self->priv = LAZY_MENU_BUTTON_GET_PRIVATE (self);
}


static void lazy_menu_button_finalize (GObject* obj) {
	LazyMenuButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_LAZY_MENU_BUTTON, LazyMenuButton);
	_g_object_unref0 (self->priv->_menu_model);
	G_OBJECT_CLASS (lazy_menu_button_parent_class)->finalize (obj);
}


GType lazy_menu_button_get_type (void) {
	static volatile gsize lazy_menu_button_type_id__volatile = 0;
	if (g_once_init_enter (&lazy_menu_button_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (LazyMenuButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) lazy_menu_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LazyMenuButton), 0, (GInstanceInitFunc) lazy_menu_button_instance_init, NULL };
		GType lazy_menu_button_type_id;
		lazy_menu_button_type_id = g_type_register_static (gtk_toggle_button_get_type (), "LazyMenuButton", &g_define_type_info, 0);
		g_once_init_leave (&lazy_menu_button_type_id__volatile, lazy_menu_button_type_id);
	}
	return lazy_menu_button_type_id__volatile;
}


static void _vala_lazy_menu_button_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	LazyMenuButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_LAZY_MENU_BUTTON, LazyMenuButton);
	switch (property_id) {
		case LAZY_MENU_BUTTON_MENU_MODEL:
		g_value_set_object (value, lazy_menu_button_get_menu_model (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_lazy_menu_button_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	LazyMenuButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_LAZY_MENU_BUTTON, LazyMenuButton);
	switch (property_id) {
		case LAZY_MENU_BUTTON_MENU_MODEL:
		lazy_menu_button_set_menu_model (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



