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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*-
 *
 * Copyright (C) 2011,2012 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 * Authors: Andrea Cimitan <andrea.cimitan@canonical.com>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <cairo-gobject.h>
#include <glib.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_MENU (menu_get_type ())
#define MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MENU, Menu))
#define MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MENU, MenuClass))
#define IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MENU))
#define IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MENU))
#define MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MENU, MenuClass))

typedef struct _Menu Menu;
typedef struct _MenuClass MenuClass;
typedef struct _MenuPrivate MenuPrivate;

#define TYPE_BACKGROUND (background_get_type ())
#define BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BACKGROUND, Background))
#define BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BACKGROUND, BackgroundClass))
#define IS_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BACKGROUND))
#define IS_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BACKGROUND))
#define BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BACKGROUND, BackgroundClass))

typedef struct _Background Background;
typedef struct _BackgroundClass BackgroundClass;
enum  {
	MENU_0_PROPERTY,
	MENU_BACKGROUND_PROPERTY,
	MENU_NUM_PROPERTIES
};
static GParamSpec* menu_properties[MENU_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef enum  {
	BACKGROUND_DRAW_FLAGS_NONE = 1 << 0,
	BACKGROUND_DRAW_FLAGS_GRID = 1 << 1,
	BACKGROUND_DRAW_FLAGS_SPAN = 1 << 2
} BackgroundDrawFlags;

#define BACKGROUND_TYPE_DRAW_FLAGS (background_draw_flags_get_type ())

struct _Menu {
	GtkMenu parent_instance;
	MenuPrivate * priv;
};

struct _MenuClass {
	GtkMenuClass parent_class;
};

struct _MenuPrivate {
	Background* _background;
};

static gint Menu_private_offset;
static gpointer menu_parent_class = NULL;

VALA_EXTERN GType menu_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Menu, g_object_unref)
VALA_EXTERN GType background_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Background, g_object_unref)
VALA_EXTERN Menu* menu_new (Background* bg);
VALA_EXTERN Menu* menu_construct (GType object_type,
                      Background* bg);
static gboolean menu_real_draw (GtkWidget* base,
                         cairo_t* c);
VALA_EXTERN Background* menu_get_background (Menu* self);
VALA_EXTERN GType background_draw_flags_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void background_draw_full (Background* self,
                           cairo_t* c,
                           BackgroundDrawFlags flags);
static void menu_set_background (Menu* self,
                          Background* value);
static void menu_finalize (GObject * obj);
static GType menu_get_type_once (void);
static void _vala_menu_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec);
static void _vala_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
menu_get_instance_private (Menu* self)
{
	return G_STRUCT_MEMBER_P (self, Menu_private_offset);
}

Menu*
menu_construct (GType object_type,
                Background* bg)
{
	Menu * self = NULL;
#line 25 "../src/menu.vala"
	g_return_val_if_fail (bg != NULL, NULL);
#line 27 "../src/menu.vala"
	self = (Menu*) g_object_new (object_type, "background", bg, NULL);
#line 25 "../src/menu.vala"
	return self;
#line 148 "menu.c"
}

Menu*
menu_new (Background* bg)
{
#line 25 "../src/menu.vala"
	return menu_construct (TYPE_MENU, bg);
#line 156 "menu.c"
}

static gboolean
menu_real_draw (GtkWidget* base,
                cairo_t* c)
{
	Menu * self;
	Background* _tmp0_;
	gboolean result;
#line 30 "../src/menu.vala"
	self = (Menu*) base;
#line 30 "../src/menu.vala"
	g_return_val_if_fail (c != NULL, FALSE);
#line 32 "../src/menu.vala"
	_tmp0_ = self->priv->_background;
#line 32 "../src/menu.vala"
	if (_tmp0_ != NULL) {
#line 174 "menu.c"
		gint x = 0;
		gint y = 0;
		gint bg_x = 0;
		gint bg_y = 0;
		Background* _tmp1_;
		GdkWindow* _tmp2_;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		GdkWindow* _tmp5_;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		Background* _tmp8_;
#line 36 "../src/menu.vala"
		_tmp1_ = self->priv->_background;
#line 36 "../src/menu.vala"
		_tmp2_ = gtk_widget_get_window ((GtkWidget*) _tmp1_);
#line 36 "../src/menu.vala"
		gdk_window_get_origin (_tmp2_, &_tmp3_, &_tmp4_);
#line 36 "../src/menu.vala"
		bg_x = _tmp3_;
#line 36 "../src/menu.vala"
		bg_y = _tmp4_;
#line 37 "../src/menu.vala"
		_tmp5_ = gtk_widget_get_window ((GtkWidget*) self);
#line 37 "../src/menu.vala"
		gdk_window_get_origin (_tmp5_, &_tmp6_, &_tmp7_);
#line 37 "../src/menu.vala"
		x = _tmp6_;
#line 37 "../src/menu.vala"
		y = _tmp7_;
#line 38 "../src/menu.vala"
		cairo_save (c);
#line 39 "../src/menu.vala"
		cairo_translate (c, (gdouble) (bg_x - x), (gdouble) (bg_y - y));
#line 40 "../src/menu.vala"
		_tmp8_ = self->priv->_background;
#line 40 "../src/menu.vala"
		background_draw_full (_tmp8_, c, BACKGROUND_DRAW_FLAGS_NONE);
#line 41 "../src/menu.vala"
		cairo_restore (c);
#line 215 "menu.c"
	}
#line 44 "../src/menu.vala"
	GTK_WIDGET_CLASS (menu_parent_class)->draw ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_menu_get_type (), GtkMenu), c);
#line 45 "../src/menu.vala"
	result = FALSE;
#line 45 "../src/menu.vala"
	return result;
#line 223 "menu.c"
}

Background*
menu_get_background (Menu* self)
{
	Background* result;
	Background* _tmp0_;
#line 23 "../src/menu.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 23 "../src/menu.vala"
	_tmp0_ = self->priv->_background;
#line 23 "../src/menu.vala"
	result = _tmp0_;
#line 23 "../src/menu.vala"
	return result;
#line 239 "menu.c"
}

static gpointer
_g_object_ref0 (gpointer self)
{
#line 23 "../src/menu.vala"
	return self ? g_object_ref (self) : NULL;
#line 247 "menu.c"
}

static void
menu_set_background (Menu* self,
                     Background* value)
{
	Background* old_value;
#line 23 "../src/menu.vala"
	g_return_if_fail (self != NULL);
#line 23 "../src/menu.vala"
	old_value = menu_get_background (self);
#line 23 "../src/menu.vala"
	if (old_value != value) {
#line 261 "menu.c"
		Background* _tmp0_;
#line 23 "../src/menu.vala"
		_tmp0_ = _g_object_ref0 (value);
#line 23 "../src/menu.vala"
		_g_object_unref0 (self->priv->_background);
#line 23 "../src/menu.vala"
		self->priv->_background = _tmp0_;
#line 23 "../src/menu.vala"
		g_object_notify_by_pspec ((GObject *) self, menu_properties[MENU_BACKGROUND_PROPERTY]);
#line 271 "menu.c"
	}
}

static void
menu_class_init (MenuClass * klass,
                 gpointer klass_data)
{
#line 21 "../src/menu.vala"
	menu_parent_class = g_type_class_peek_parent (klass);
#line 21 "../src/menu.vala"
	g_type_class_adjust_private_offset (klass, &Menu_private_offset);
#line 21 "../src/menu.vala"
	((GtkWidgetClass *) klass)->draw = (gboolean (*) (GtkWidget*, cairo_t*)) menu_real_draw;
#line 21 "../src/menu.vala"
	G_OBJECT_CLASS (klass)->get_property = _vala_menu_get_property;
#line 21 "../src/menu.vala"
	G_OBJECT_CLASS (klass)->set_property = _vala_menu_set_property;
#line 21 "../src/menu.vala"
	G_OBJECT_CLASS (klass)->finalize = menu_finalize;
#line 21 "../src/menu.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), MENU_BACKGROUND_PROPERTY, menu_properties[MENU_BACKGROUND_PROPERTY] = g_param_spec_object ("background", "background", "background", TYPE_BACKGROUND, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
#line 293 "menu.c"
}

static void
menu_instance_init (Menu * self,
                    gpointer klass)
{
#line 21 "../src/menu.vala"
	self->priv = menu_get_instance_private (self);
#line 23 "../src/menu.vala"
	self->priv->_background = NULL;
#line 304 "menu.c"
}

static void
menu_finalize (GObject * obj)
{
	Menu * self;
#line 21 "../src/menu.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MENU, Menu);
#line 23 "../src/menu.vala"
	_g_object_unref0 (self->priv->_background);
#line 21 "../src/menu.vala"
	G_OBJECT_CLASS (menu_parent_class)->finalize (obj);
#line 317 "menu.c"
}

static GType
menu_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MenuClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) menu_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Menu), 0, (GInstanceInitFunc) menu_instance_init, NULL };
	GType menu_type_id;
	menu_type_id = g_type_register_static (gtk_menu_get_type (), "Menu", &g_define_type_info, 0);
	Menu_private_offset = g_type_add_instance_private (menu_type_id, sizeof (MenuPrivate));
	return menu_type_id;
}

GType
menu_get_type (void)
{
	static volatile gsize menu_type_id__once = 0;
	if (g_once_init_enter (&menu_type_id__once)) {
		GType menu_type_id;
		menu_type_id = menu_get_type_once ();
		g_once_init_leave (&menu_type_id__once, menu_type_id);
	}
	return menu_type_id__once;
}

static void
_vala_menu_get_property (GObject * object,
                         guint property_id,
                         GValue * value,
                         GParamSpec * pspec)
{
	Menu * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MENU, Menu);
#line 21 "../src/menu.vala"
	switch (property_id) {
#line 21 "../src/menu.vala"
		case MENU_BACKGROUND_PROPERTY:
#line 21 "../src/menu.vala"
		g_value_set_object (value, menu_get_background (self));
#line 21 "../src/menu.vala"
		break;
#line 358 "menu.c"
		default:
#line 21 "../src/menu.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 21 "../src/menu.vala"
		break;
#line 364 "menu.c"
	}
}

static void
_vala_menu_set_property (GObject * object,
                         guint property_id,
                         const GValue * value,
                         GParamSpec * pspec)
{
	Menu * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MENU, Menu);
#line 21 "../src/menu.vala"
	switch (property_id) {
#line 21 "../src/menu.vala"
		case MENU_BACKGROUND_PROPERTY:
#line 21 "../src/menu.vala"
		menu_set_background (self, g_value_get_object (value));
#line 21 "../src/menu.vala"
		break;
#line 384 "menu.c"
		default:
#line 21 "../src/menu.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 21 "../src/menu.vala"
		break;
#line 390 "menu.c"
	}
}

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

