/* menu.c generated by valac 0.16.1, 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 .
*
* Authors: Andrea Cimitan
*/
#include
#include
#include
#include
#include
#include
#include
#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;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#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;
};
typedef enum {
BACKGROUND_DRAW_FLAGS_NONE,
BACKGROUND_DRAW_FLAGS_GRID
} BackgroundDrawFlags;
static gpointer menu_parent_class = NULL;
GType menu_get_type (void) G_GNUC_CONST;
GType background_get_type (void) G_GNUC_CONST;
#define MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MENU, MenuPrivate))
enum {
MENU_DUMMY_PROPERTY,
MENU_BACKGROUND
};
Menu* menu_new (Background* bg);
Menu* menu_construct (GType object_type, Background* bg);
static gboolean menu_real_draw (GtkWidget* base, cairo_t* c);
Background* menu_get_background (Menu* self);
GType background_draw_flags_get_type (void) G_GNUC_CONST;
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 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);
Menu* menu_construct (GType object_type, Background* bg) {
Menu * self = NULL;
Background* _tmp0_;
g_return_val_if_fail (bg != NULL, NULL);
_tmp0_ = bg;
self = (Menu*) g_object_new (object_type, "background", _tmp0_, NULL);
return self;
}
Menu* menu_new (Background* bg) {
return menu_construct (TYPE_MENU, bg);
}
static gboolean menu_real_draw (GtkWidget* base, cairo_t* c) {
Menu * self;
gboolean result = FALSE;
Background* _tmp0_;
cairo_t* _tmp17_;
self = (Menu*) base;
g_return_val_if_fail (c != NULL, FALSE);
_tmp0_ = self->priv->_background;
if (_tmp0_ != NULL) {
gint x = 0;
gint y = 0;
gint bg_x = 0;
gint bg_y = 0;
Background* _tmp1_;
GdkWindow* _tmp2_ = NULL;
gint _tmp3_ = 0;
gint _tmp4_ = 0;
GdkWindow* _tmp5_ = NULL;
gint _tmp6_ = 0;
gint _tmp7_ = 0;
cairo_t* _tmp8_;
cairo_t* _tmp9_;
gint _tmp10_;
gint _tmp11_;
gint _tmp12_;
gint _tmp13_;
Background* _tmp14_;
cairo_t* _tmp15_;
cairo_t* _tmp16_;
_tmp1_ = self->priv->_background;
_tmp2_ = gtk_widget_get_window ((GtkWidget*) _tmp1_);
gdk_window_get_origin (_tmp2_, &_tmp3_, &_tmp4_);
bg_x = _tmp3_;
bg_y = _tmp4_;
_tmp5_ = gtk_widget_get_window ((GtkWidget*) self);
gdk_window_get_origin (_tmp5_, &_tmp6_, &_tmp7_);
x = _tmp6_;
y = _tmp7_;
_tmp8_ = c;
cairo_save (_tmp8_);
_tmp9_ = c;
_tmp10_ = bg_x;
_tmp11_ = x;
_tmp12_ = bg_y;
_tmp13_ = y;
cairo_translate (_tmp9_, (gdouble) (_tmp10_ - _tmp11_), (gdouble) (_tmp12_ - _tmp13_));
_tmp14_ = self->priv->_background;
_tmp15_ = c;
background_draw_full (_tmp14_, _tmp15_, BACKGROUND_DRAW_FLAGS_NONE);
_tmp16_ = c;
cairo_restore (_tmp16_);
}
_tmp17_ = c;
GTK_WIDGET_CLASS (menu_parent_class)->draw ((GtkWidget*) GTK_MENU (self), _tmp17_);
result = FALSE;
return result;
}
Background* menu_get_background (Menu* self) {
Background* result;
Background* _tmp0_;
g_return_val_if_fail (self != NULL, NULL);
_tmp0_ = self->priv->_background;
result = _tmp0_;
return result;
}
static gpointer _g_object_ref0 (gpointer self) {
return self ? g_object_ref (self) : NULL;
}
static void menu_set_background (Menu* self, Background* value) {
Background* _tmp0_;
Background* _tmp1_;
g_return_if_fail (self != NULL);
_tmp0_ = value;
_tmp1_ = _g_object_ref0 (_tmp0_);
_g_object_unref0 (self->priv->_background);
self->priv->_background = _tmp1_;
g_object_notify ((GObject *) self, "background");
}
static void menu_class_init (MenuClass * klass) {
menu_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (MenuPrivate));
GTK_WIDGET_CLASS (klass)->draw = menu_real_draw;
G_OBJECT_CLASS (klass)->get_property = _vala_menu_get_property;
G_OBJECT_CLASS (klass)->set_property = _vala_menu_set_property;
G_OBJECT_CLASS (klass)->finalize = menu_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), MENU_BACKGROUND, g_param_spec_object ("background", "background", "background", TYPE_BACKGROUND, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}
static void menu_instance_init (Menu * self) {
self->priv = MENU_GET_PRIVATE (self);
self->priv->_background = NULL;
}
static void menu_finalize (GObject* obj) {
Menu * self;
self = MENU (obj);
_g_object_unref0 (self->priv->_background);
G_OBJECT_CLASS (menu_parent_class)->finalize (obj);
}
GType menu_get_type (void) {
static volatile gsize menu_type_id__volatile = 0;
if (g_once_init_enter (&menu_type_id__volatile)) {
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_TYPE_MENU, "Menu", &g_define_type_info, 0);
g_once_init_leave (&menu_type_id__volatile, menu_type_id);
}
return menu_type_id__volatile;
}
static void _vala_menu_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
Menu * self;
self = MENU (object);
switch (property_id) {
case MENU_BACKGROUND:
g_value_set_object (value, menu_get_background (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void _vala_menu_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
Menu * self;
self = MENU (object);
switch (property_id) {
case MENU_BACKGROUND:
menu_set_background (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}