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


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <stdio.h>


#define TYPE_INDICATOR_VIEW (indicator_view_get_type ())
#define INDICATOR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_INDICATOR_VIEW, IndicatorView))
#define IS_INDICATOR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_INDICATOR_VIEW))
#define INDICATOR_VIEW_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_INDICATOR_VIEW, IndicatorViewIface))

typedef struct _IndicatorView IndicatorView;
typedef struct _IndicatorViewIface IndicatorViewIface;

#define TYPE_TRAY_INDICATOR_VIEW (tray_indicator_view_get_type ())
#define TRAY_INDICATOR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorView))
#define TRAY_INDICATOR_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorViewClass))
#define IS_TRAY_INDICATOR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRAY_INDICATOR_VIEW))
#define IS_TRAY_INDICATOR_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TRAY_INDICATOR_VIEW))
#define TRAY_INDICATOR_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorViewClass))

typedef struct _TrayIndicatorView TrayIndicatorView;
typedef struct _TrayIndicatorViewClass TrayIndicatorViewClass;
typedef struct _TrayIndicatorViewPrivate TrayIndicatorViewPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block4Data Block4Data;
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))

struct _IndicatorViewIface {
	GTypeInterface parent_iface;
	void (*set_label) (IndicatorView* self, const gchar* value);
	void (*set_guide) (IndicatorView* self, const gchar* value);
	void (*set_icon) (IndicatorView* self, const gchar* value);
	void (*set_description) (IndicatorView* self, const gchar* value);
};

struct _TrayIndicatorView {
	GObject parent_instance;
	TrayIndicatorViewPrivate * priv;
};

struct _TrayIndicatorViewClass {
	GObjectClass parent_class;
};

struct _TrayIndicatorViewPrivate {
	GtkStatusIcon* indicator;
	gchar* icondirectory;
};

struct _Block4Data {
	int _ref_count_;
	TrayIndicatorView * self;
	GtkMenu* menu;
};


static gpointer tray_indicator_view_parent_class = NULL;
static IndicatorViewIface* tray_indicator_view_indicator_view_parent_iface = NULL;

GType indicator_view_get_type (void) G_GNUC_CONST;
GType tray_indicator_view_get_type (void) G_GNUC_CONST;
#define TRAY_INDICATOR_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorViewPrivate))
enum  {
	TRAY_INDICATOR_VIEW_DUMMY_PROPERTY,
	TRAY_INDICATOR_VIEW_LABEL,
	TRAY_INDICATOR_VIEW_GUIDE,
	TRAY_INDICATOR_VIEW_ICON,
	TRAY_INDICATOR_VIEW_DESCRIPTION
};
TrayIndicatorView* tray_indicator_view_new (const gchar* icondirectory, GtkMenu* menu);
TrayIndicatorView* tray_indicator_view_construct (GType object_type, const gchar* icondirectory, GtkMenu* menu);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void __lambda11_ (Block4Data* _data4_);
static void _gtk_status_icon_position_menu_gtk_menu_position_func (GtkMenu* menu, gint* x, gint* y, gboolean* push_in, gpointer self);
static void ___lambda11__gtk_status_icon_activate (GtkStatusIcon* _sender, gpointer self);
static void __lambda12_ (Block4Data* _data4_, guint button, guint activate_time);
static void ___lambda12__gtk_status_icon_popup_menu (GtkStatusIcon* _sender, guint button, guint activate_time, gpointer self);
static gboolean __lambda13_ (TrayIndicatorView* self, GdkEventScroll* event);
static gboolean ___lambda13__gtk_status_icon_scroll_event (GtkStatusIcon* _sender, GdkEventScroll* event, gpointer self);
static gboolean __lambda14_ (Block4Data* _data4_, GdkEventButton* event);
static gboolean ___lambda14__gtk_status_icon_button_release_event (GtkStatusIcon* _sender, GdkEventButton* event, gpointer self);
static void tray_indicator_view_finalize (GObject* obj);
void indicator_view_set_label (IndicatorView* self, const gchar* value);
void indicator_view_set_guide (IndicatorView* self, const gchar* value);
void indicator_view_set_icon (IndicatorView* self, const gchar* value);
void indicator_view_set_description (IndicatorView* self, const gchar* value);
static void _vala_tray_indicator_view_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


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


static Block4Data* block4_data_ref (Block4Data* _data4_) {
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}


static void block4_data_unref (void * _userdata_) {
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		TrayIndicatorView * self;
		self = _data4_->self;
		_g_object_unref0 (_data4_->menu);
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}


static void _gtk_status_icon_position_menu_gtk_menu_position_func (GtkMenu* menu, gint* x, gint* y, gboolean* push_in, gpointer self) {
	gtk_status_icon_position_menu (menu, x, y, push_in, self);
}


static void __lambda11_ (Block4Data* _data4_) {
	TrayIndicatorView * self;
	GtkMenu* _tmp0_ = NULL;
	GtkStatusIcon* _tmp1_ = NULL;
	guint32 _tmp2_ = 0U;
	self = _data4_->self;
	_tmp0_ = _data4_->menu;
	_tmp1_ = self->priv->indicator;
	_tmp2_ = gtk_get_current_event_time ();
	gtk_menu_popup (_tmp0_, NULL, NULL, _gtk_status_icon_position_menu_gtk_menu_position_func, _tmp1_, (guint) 1, _tmp2_);
}


static void ___lambda11__gtk_status_icon_activate (GtkStatusIcon* _sender, gpointer self) {
	__lambda11_ (self);
}


static void __lambda12_ (Block4Data* _data4_, guint button, guint activate_time) {
	TrayIndicatorView * self;
	GtkMenu* _tmp0_ = NULL;
	GtkStatusIcon* _tmp1_ = NULL;
	guint _tmp2_ = 0U;
	guint _tmp3_ = 0U;
	self = _data4_->self;
	_tmp0_ = _data4_->menu;
	_tmp1_ = self->priv->indicator;
	_tmp2_ = button;
	_tmp3_ = activate_time;
	gtk_menu_popup (_tmp0_, NULL, NULL, _gtk_status_icon_position_menu_gtk_menu_position_func, _tmp1_, _tmp2_, (guint32) _tmp3_);
}


static void ___lambda12__gtk_status_icon_popup_menu (GtkStatusIcon* _sender, guint button, guint activate_time, gpointer self) {
	__lambda12_ (self, button, activate_time);
}


static gboolean __lambda13_ (TrayIndicatorView* self, GdkEventScroll* event) {
	gboolean result = FALSE;
	GdkEventScroll _tmp0_ = {0};
	GdkScrollDirection _tmp1_ = 0;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = *event;
	_tmp1_ = _tmp0_.direction;
	g_signal_emit_by_name (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_INDICATOR_VIEW, IndicatorView), "scroll-event", 1, (guint) _tmp1_);
	result = TRUE;
	return result;
}


static gboolean ___lambda13__gtk_status_icon_scroll_event (GtkStatusIcon* _sender, GdkEventScroll* event, gpointer self) {
	gboolean result;
	result = __lambda13_ (self, event);
	return result;
}


static gboolean __lambda14_ (Block4Data* _data4_, GdkEventButton* event) {
	TrayIndicatorView * self;
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GdkEventButton _tmp1_ = {0};
	guint _tmp2_ = 0U;
	gboolean _tmp5_ = FALSE;
	self = _data4_->self;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp1_ = *event;
	_tmp2_ = _tmp1_.button;
	if (_tmp2_ == ((guint) 2)) {
		GdkEventButton _tmp3_ = {0};
		GdkEventType _tmp4_ = 0;
		_tmp3_ = *event;
		_tmp4_ = _tmp3_.type;
		_tmp0_ = _tmp4_ == GDK_BUTTON_RELEASE;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp5_ = _tmp0_;
	if (_tmp5_) {
		GtkMenu* _tmp6_ = NULL;
		GList* _tmp7_ = NULL;
		GList* _tmp8_ = NULL;
		gconstpointer _tmp9_ = NULL;
		_tmp6_ = _data4_->menu;
		_tmp7_ = gtk_container_get_children (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GTK_TYPE_CONTAINER, GtkContainer));
		_tmp8_ = _tmp7_;
		_tmp9_ = _tmp8_->data;
		gtk_widget_activate ((GtkWidget*) _tmp9_);
		_g_list_free0 (_tmp8_);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


static gboolean ___lambda14__gtk_status_icon_button_release_event (GtkStatusIcon* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = __lambda14_ (self, event);
	return result;
}


TrayIndicatorView* tray_indicator_view_construct (GType object_type, const gchar* icondirectory, GtkMenu* menu) {
	TrayIndicatorView * self = NULL;
	Block4Data* _data4_;
	GtkMenu* _tmp0_ = NULL;
	GtkMenu* _tmp1_ = NULL;
	GtkStatusIcon* _tmp2_ = NULL;
	GtkStatusIcon* _tmp3_ = NULL;
	GtkStatusIcon* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	GtkStatusIcon* _tmp7_ = NULL;
	GtkStatusIcon* _tmp8_ = NULL;
	GtkStatusIcon* _tmp9_ = NULL;
	GtkStatusIcon* _tmp10_ = NULL;
	g_return_val_if_fail (icondirectory != NULL, NULL);
	g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_tmp0_ = menu;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (_data4_->menu);
	_data4_->menu = _tmp1_;
	self = (TrayIndicatorView*) g_object_new (object_type, NULL);
	_data4_->self = g_object_ref (self);
	_tmp2_ = gtk_status_icon_new ();
	_g_object_unref0 (self->priv->indicator);
	self->priv->indicator = _tmp2_;
	_tmp3_ = self->priv->indicator;
	gtk_status_icon_set_name (_tmp3_, "Wine");
	_tmp4_ = self->priv->indicator;
	gtk_status_icon_set_visible (_tmp4_, TRUE);
	_tmp5_ = icondirectory;
	_tmp6_ = g_strdup (_tmp5_);
	_g_free0 (self->priv->icondirectory);
	self->priv->icondirectory = _tmp6_;
	_tmp7_ = self->priv->indicator;
	g_signal_connect_data (_tmp7_, "activate", (GCallback) ___lambda11__gtk_status_icon_activate, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
	_tmp8_ = self->priv->indicator;
	g_signal_connect_data (_tmp8_, "popup-menu", (GCallback) ___lambda12__gtk_status_icon_popup_menu, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
	_tmp9_ = self->priv->indicator;
	g_signal_connect_object (_tmp9_, "scroll-event", (GCallback) ___lambda13__gtk_status_icon_scroll_event, self, 0);
	_tmp10_ = self->priv->indicator;
	g_signal_connect_data (_tmp10_, "button-release-event", (GCallback) ___lambda14__gtk_status_icon_button_release_event, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
	block4_data_unref (_data4_);
	_data4_ = NULL;
	return self;
}


TrayIndicatorView* tray_indicator_view_new (const gchar* icondirectory, GtkMenu* menu) {
	return tray_indicator_view_construct (TYPE_TRAY_INDICATOR_VIEW, icondirectory, menu);
}


static void tray_indicator_view_real_set_label (IndicatorView* base, const gchar* value) {
	TrayIndicatorView* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorView);
	g_object_notify ((GObject *) self, "label");
}


static void tray_indicator_view_real_set_guide (IndicatorView* base, const gchar* value) {
	TrayIndicatorView* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorView);
	g_object_notify ((GObject *) self, "guide");
}


static void tray_indicator_view_real_set_icon (IndicatorView* base, const gchar* value) {
	TrayIndicatorView* self;
	gchar* path = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	FILE* _tmp6_ = NULL;
	GtkStatusIcon* _tmp7_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorView);
	_tmp0_ = self->priv->icondirectory;
	_tmp1_ = value;
	_tmp2_ = g_strconcat (_tmp1_, ".png", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_build_filename (_tmp0_, _tmp3_, NULL);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	path = _tmp5_;
	_tmp6_ = stdout;
	fprintf (_tmp6_, "%s\n", path);
	_tmp7_ = self->priv->indicator;
	gtk_status_icon_set_from_file (_tmp7_, path);
	_g_free0 (path);
	g_object_notify ((GObject *) self, "icon");
}


static void tray_indicator_view_real_set_description (IndicatorView* base, const gchar* value) {
	TrayIndicatorView* self;
	GtkStatusIcon* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorView);
	_tmp0_ = self->priv->indicator;
	_tmp1_ = value;
	gtk_status_icon_set_tooltip_text (_tmp0_, _tmp1_);
	g_object_notify ((GObject *) self, "description");
}


static void tray_indicator_view_class_init (TrayIndicatorViewClass * klass) {
	tray_indicator_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (TrayIndicatorViewPrivate));
	G_OBJECT_CLASS (klass)->set_property = _vala_tray_indicator_view_set_property;
	G_OBJECT_CLASS (klass)->finalize = tray_indicator_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TRAY_INDICATOR_VIEW_LABEL, g_param_spec_string ("label", "label", "label", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TRAY_INDICATOR_VIEW_GUIDE, g_param_spec_string ("guide", "guide", "guide", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TRAY_INDICATOR_VIEW_ICON, g_param_spec_string ("icon", "icon", "icon", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TRAY_INDICATOR_VIEW_DESCRIPTION, g_param_spec_string ("description", "description", "description", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE));
}


static void tray_indicator_view_indicator_view_interface_init (IndicatorViewIface * iface) {
	tray_indicator_view_indicator_view_parent_iface = g_type_interface_peek_parent (iface);
	iface->set_label = tray_indicator_view_real_set_label;
	iface->set_guide = tray_indicator_view_real_set_guide;
	iface->set_icon = tray_indicator_view_real_set_icon;
	iface->set_description = tray_indicator_view_real_set_description;
}


static void tray_indicator_view_instance_init (TrayIndicatorView * self) {
	self->priv = TRAY_INDICATOR_VIEW_GET_PRIVATE (self);
}


static void tray_indicator_view_finalize (GObject* obj) {
	TrayIndicatorView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorView);
	_g_object_unref0 (self->priv->indicator);
	_g_free0 (self->priv->icondirectory);
	G_OBJECT_CLASS (tray_indicator_view_parent_class)->finalize (obj);
}


/******************************************************************************
 * Copyright (C) 2011-2013  Michael Hofmann <mh21@mh21.de>                    *
 *                                                                            *
 * 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 3 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.                *
 ******************************************************************************/
GType tray_indicator_view_get_type (void) {
	static volatile gsize tray_indicator_view_type_id__volatile = 0;
	if (g_once_init_enter (&tray_indicator_view_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (TrayIndicatorViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tray_indicator_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TrayIndicatorView), 0, (GInstanceInitFunc) tray_indicator_view_instance_init, NULL };
		static const GInterfaceInfo indicator_view_info = { (GInterfaceInitFunc) tray_indicator_view_indicator_view_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType tray_indicator_view_type_id;
		tray_indicator_view_type_id = g_type_register_static (G_TYPE_OBJECT, "TrayIndicatorView", &g_define_type_info, 0);
		g_type_add_interface_static (tray_indicator_view_type_id, TYPE_INDICATOR_VIEW, &indicator_view_info);
		g_once_init_leave (&tray_indicator_view_type_id__volatile, tray_indicator_view_type_id);
	}
	return tray_indicator_view_type_id__volatile;
}


static void _vala_tray_indicator_view_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	TrayIndicatorView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TRAY_INDICATOR_VIEW, TrayIndicatorView);
	switch (property_id) {
		case TRAY_INDICATOR_VIEW_LABEL:
		indicator_view_set_label (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_INDICATOR_VIEW, IndicatorView), g_value_get_string (value));
		break;
		case TRAY_INDICATOR_VIEW_GUIDE:
		indicator_view_set_guide (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_INDICATOR_VIEW, IndicatorView), g_value_get_string (value));
		break;
		case TRAY_INDICATOR_VIEW_ICON:
		indicator_view_set_icon (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_INDICATOR_VIEW, IndicatorView), g_value_get_string (value));
		break;
		case TRAY_INDICATOR_VIEW_DESCRIPTION:
		indicator_view_set_description (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_INDICATOR_VIEW, IndicatorView), g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



