/* contacts-clickable.c generated by valac 0.20.1.71-45f6, the Vala compiler
 * generated from contacts-clickable.vala, do not modify */

/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
/*
 * Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

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


#define CONTACTS_TYPE_CLICKABLE (contacts_clickable_get_type ())
#define CONTACTS_CLICKABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_CLICKABLE, ContactsClickable))
#define CONTACTS_CLICKABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_CLICKABLE, ContactsClickableClass))
#define CONTACTS_IS_CLICKABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_CLICKABLE))
#define CONTACTS_IS_CLICKABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_CLICKABLE))
#define CONTACTS_CLICKABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_CLICKABLE, ContactsClickableClass))

typedef struct _ContactsClickable ContactsClickable;
typedef struct _ContactsClickableClass ContactsClickableClass;
typedef struct _ContactsClickablePrivate ContactsClickablePrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ContactsClickable {
	GObject parent_instance;
	ContactsClickablePrivate * priv;
	GtkStateFlags state;
};

struct _ContactsClickableClass {
	GObjectClass parent_class;
	void (*activate) (ContactsClickable* self);
};

struct _ContactsClickablePrivate {
	GtkWidget* widget;
	gboolean in_button;
	gboolean button_down;
	gboolean depressed;
	gboolean depress_on_activate;
	gboolean focus_on_click;
	guint activate_timeout;
	guint32 grab_time;
	GdkDevice* grab_keyboard;
	GdkWindow* event_window;
};


static gpointer contacts_clickable_parent_class = NULL;

GType contacts_clickable_get_type (void) G_GNUC_CONST;
#define CONTACTS_CLICKABLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CONTACTS_TYPE_CLICKABLE, ContactsClickablePrivate))
enum  {
	CONTACTS_CLICKABLE_DUMMY_PROPERTY
};
ContactsClickable* contacts_clickable_new (GtkWidget* w);
ContactsClickable* contacts_clickable_construct (GType object_type, GtkWidget* w);
static gboolean contacts_clickable_button_press_event (ContactsClickable* self, GdkEventButton* event);
static gboolean _contacts_clickable_button_press_event_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static gboolean contacts_clickable_button_release_event (ContactsClickable* self, GdkEventButton* event);
static gboolean _contacts_clickable_button_release_event_gtk_widget_button_release_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static gboolean contacts_clickable_enter_notify_event (ContactsClickable* self, GdkEventCrossing* event);
static gboolean _contacts_clickable_enter_notify_event_gtk_widget_enter_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self);
static gboolean contacts_clickable_leave_notify_event (ContactsClickable* self, GdkEventCrossing* event);
static gboolean _contacts_clickable_leave_notify_event_gtk_widget_leave_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self);
static gboolean contacts_clickable_grab_broken_event (ContactsClickable* self, GdkEventGrabBroken* event);
static gboolean _contacts_clickable_grab_broken_event_gtk_widget_grab_broken_event (GtkWidget* _sender, GdkEventGrabBroken* event, gpointer self);
static void contacts_clickable_state_changed (ContactsClickable* self, GtkStateType previous_state);
static void _contacts_clickable_state_changed_gtk_widget_state_changed (GtkWidget* _sender, GtkStateType previous_state, gpointer self);
static void contacts_clickable_grab_notify (ContactsClickable* self, gboolean was_grabbed);
static void _contacts_clickable_grab_notify_gtk_widget_grab_notify (GtkWidget* _sender, gboolean was_grabbed, gpointer self);
void contacts_clickable_set_focus_on_click (ContactsClickable* self, gboolean focus_on_click);
void contacts_clickable_realize_for (ContactsClickable* self, GdkWindow* event_window);
void contacts_clickable_unrealize (ContactsClickable* self);
static void contacts_clickable_finish_activate (ContactsClickable* self, gboolean do_it);
static GdkWindow* contacts_clickable_get_event_window (ContactsClickable* self);
static void contacts_clickable_set_depressed (ContactsClickable* self, gboolean depressed);
static void contacts_clickable_pressed (ContactsClickable* self);
static void contacts_clickable_released (ContactsClickable* self);
static void contacts_clickable_update_state (ContactsClickable* self);
static gboolean contacts_clickable_activate_timeout_cb (ContactsClickable* self);
static void contacts_clickable_real_activate (ContactsClickable* self);
static gboolean _contacts_clickable_activate_timeout_cb_gsource_func (gpointer self);
static void contacts_clickable_finalize (GObject* obj);


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


static gboolean _contacts_clickable_button_press_event_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = contacts_clickable_button_press_event (self, event);
	return result;
}


static gboolean _contacts_clickable_button_release_event_gtk_widget_button_release_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = contacts_clickable_button_release_event (self, event);
	return result;
}


static gboolean _contacts_clickable_enter_notify_event_gtk_widget_enter_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self) {
	gboolean result;
	result = contacts_clickable_enter_notify_event (self, event);
	return result;
}


static gboolean _contacts_clickable_leave_notify_event_gtk_widget_leave_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self) {
	gboolean result;
	result = contacts_clickable_leave_notify_event (self, event);
	return result;
}


static gboolean _contacts_clickable_grab_broken_event_gtk_widget_grab_broken_event (GtkWidget* _sender, GdkEventGrabBroken* event, gpointer self) {
	gboolean result;
	result = contacts_clickable_grab_broken_event (self, event);
	return result;
}


static void _contacts_clickable_state_changed_gtk_widget_state_changed (GtkWidget* _sender, GtkStateType previous_state, gpointer self) {
	contacts_clickable_state_changed (self, previous_state);
}


static void _contacts_clickable_grab_notify_gtk_widget_grab_notify (GtkWidget* _sender, gboolean was_grabbed, gpointer self) {
	contacts_clickable_grab_notify (self, was_grabbed);
}


ContactsClickable* contacts_clickable_construct (GType object_type, GtkWidget* w) {
	ContactsClickable * self = NULL;
	GtkWidget* _tmp0_ = NULL;
	GtkWidget* _tmp1_ = NULL;
	GtkWidget* _tmp2_ = NULL;
	GtkWidget* _tmp3_ = NULL;
	GtkWidget* _tmp4_ = NULL;
	GtkWidget* _tmp5_ = NULL;
	GtkWidget* _tmp6_ = NULL;
	GtkWidget* _tmp7_ = NULL;
	GtkWidget* _tmp8_ = NULL;
	GtkWidget* _tmp9_ = NULL;
	g_return_val_if_fail (w != NULL, NULL);
	self = (ContactsClickable*) g_object_new (object_type, NULL);
	_tmp0_ = w;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->widget);
	self->priv->widget = _tmp1_;
	_tmp2_ = self->priv->widget;
	g_signal_connect_object (_tmp2_, "button-press-event", (GCallback) _contacts_clickable_button_press_event_gtk_widget_button_press_event, self, 0);
	_tmp3_ = self->priv->widget;
	g_signal_connect_object (_tmp3_, "button-release-event", (GCallback) _contacts_clickable_button_release_event_gtk_widget_button_release_event, self, 0);
	_tmp4_ = self->priv->widget;
	g_signal_connect_object (_tmp4_, "enter-notify-event", (GCallback) _contacts_clickable_enter_notify_event_gtk_widget_enter_notify_event, self, 0);
	_tmp5_ = self->priv->widget;
	g_signal_connect_object (_tmp5_, "leave-notify-event", (GCallback) _contacts_clickable_leave_notify_event_gtk_widget_leave_notify_event, self, 0);
	_tmp6_ = self->priv->widget;
	g_signal_connect_object (_tmp6_, "grab-broken-event", (GCallback) _contacts_clickable_grab_broken_event_gtk_widget_grab_broken_event, self, 0);
	_tmp7_ = self->priv->widget;
	g_signal_connect_object (_tmp7_, "state-changed", (GCallback) _contacts_clickable_state_changed_gtk_widget_state_changed, self, 0);
	_tmp8_ = self->priv->widget;
	g_signal_connect_object (_tmp8_, "grab-notify", (GCallback) _contacts_clickable_grab_notify_gtk_widget_grab_notify, self, 0);
	_tmp9_ = self->priv->widget;
	gtk_widget_add_events (_tmp9_, (gint) (((GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK) | GDK_BUTTON_PRESS_MASK) | GDK_BUTTON_RELEASE_MASK));
	return self;
}


ContactsClickable* contacts_clickable_new (GtkWidget* w) {
	return contacts_clickable_construct (CONTACTS_TYPE_CLICKABLE, w);
}


void contacts_clickable_set_focus_on_click (ContactsClickable* self, gboolean focus_on_click) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = focus_on_click;
	self->priv->focus_on_click = _tmp0_;
}


void contacts_clickable_realize_for (ContactsClickable* self, GdkWindow* event_window) {
	GdkWindow* _tmp0_ = NULL;
	GdkWindow* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = event_window;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->event_window);
	self->priv->event_window = _tmp1_;
}


void contacts_clickable_unrealize (ContactsClickable* self) {
	guint _tmp0_ = 0U;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->activate_timeout;
	if (_tmp0_ != ((guint) 0)) {
		contacts_clickable_finish_activate (self, FALSE);
	}
}


static GdkWindow* contacts_clickable_get_event_window (ContactsClickable* self) {
	GdkWindow* result = NULL;
	GdkWindow* _tmp0_ = NULL;
	GdkWindow* _tmp1_ = NULL;
	GdkWindow* _tmp2_ = NULL;
	GdkWindow* _tmp3_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->event_window;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_tmp0_ = _tmp2_;
	_tmp3_ = _tmp0_;
	if (_tmp3_ == NULL) {
		GtkWidget* _tmp4_ = NULL;
		GdkWindow* _tmp5_ = NULL;
		GdkWindow* _tmp6_ = NULL;
		_tmp4_ = self->priv->widget;
		_tmp5_ = gtk_widget_get_window (_tmp4_);
		_tmp6_ = _g_object_ref0 (_tmp5_);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = _tmp6_;
	}
	result = _tmp0_;
	return result;
}


static void contacts_clickable_set_depressed (ContactsClickable* self, gboolean depressed) {
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = depressed;
	_tmp1_ = self->priv->depressed;
	if (_tmp0_ != _tmp1_) {
		gboolean _tmp2_ = FALSE;
		GtkWidget* _tmp3_ = NULL;
		_tmp2_ = depressed;
		self->priv->depressed = _tmp2_;
		_tmp3_ = self->priv->widget;
		gtk_widget_queue_resize (_tmp3_);
	}
}


static gboolean contacts_clickable_button_press_event (ContactsClickable* self, GdkEventButton* event) {
	gboolean result = FALSE;
	GdkEventButton _tmp0_ = {0};
	guint _tmp1_ = 0U;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = *event;
	_tmp1_ = _tmp0_.button;
	if (_tmp1_ == ((guint) 1)) {
		gboolean _tmp2_ = FALSE;
		gboolean _tmp3_ = FALSE;
		gboolean _tmp7_ = FALSE;
		_tmp3_ = self->priv->focus_on_click;
		if (_tmp3_) {
			GtkWidget* _tmp4_ = NULL;
			gboolean _tmp5_ = FALSE;
			gboolean _tmp6_ = FALSE;
			_tmp4_ = self->priv->widget;
			g_object_get (_tmp4_, "has-focus", &_tmp5_, NULL);
			_tmp6_ = _tmp5_;
			_tmp2_ = !_tmp6_;
		} else {
			_tmp2_ = FALSE;
		}
		_tmp7_ = _tmp2_;
		if (_tmp7_) {
			GtkWidget* _tmp8_ = NULL;
			_tmp8_ = self->priv->widget;
			gtk_widget_grab_focus (_tmp8_);
		}
		contacts_clickable_pressed (self);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


static gboolean contacts_clickable_button_release_event (ContactsClickable* self, GdkEventButton* event) {
	gboolean result = FALSE;
	GdkEventButton _tmp0_ = {0};
	guint _tmp1_ = 0U;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = *event;
	_tmp1_ = _tmp0_.button;
	if (_tmp1_ == ((guint) 1)) {
		contacts_clickable_released (self);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


static gboolean contacts_clickable_grab_broken_event (ContactsClickable* self, GdkEventGrabBroken* event) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->button_down;
	if (_tmp0_) {
		gboolean save_in = FALSE;
		gboolean _tmp1_ = FALSE;
		gboolean _tmp2_ = FALSE;
		gboolean _tmp3_ = FALSE;
		_tmp1_ = self->priv->in_button;
		save_in = _tmp1_;
		self->priv->in_button = FALSE;
		contacts_clickable_released (self);
		_tmp2_ = save_in;
		_tmp3_ = self->priv->in_button;
		if (_tmp2_ != _tmp3_) {
			gboolean _tmp4_ = FALSE;
			_tmp4_ = save_in;
			self->priv->in_button = _tmp4_;
			contacts_clickable_update_state (self);
		}
	}
	result = TRUE;
	return result;
}


static gboolean contacts_clickable_enter_notify_event (ContactsClickable* self, GdkEventCrossing* event) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GdkEventCrossing _tmp1_ = {0};
	GdkWindow* _tmp2_ = NULL;
	GdkWindow* _tmp3_ = NULL;
	GdkWindow* _tmp4_ = NULL;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp8_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp1_ = *event;
	_tmp2_ = _tmp1_.window;
	_tmp3_ = contacts_clickable_get_event_window (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp2_ == _tmp4_;
	_g_object_unref0 (_tmp4_);
	if (_tmp5_) {
		GdkEventCrossing _tmp6_ = {0};
		GdkNotifyType _tmp7_ = 0;
		_tmp6_ = *event;
		_tmp7_ = _tmp6_.detail;
		_tmp0_ = _tmp7_ != GDK_NOTIFY_INFERIOR;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp8_ = _tmp0_;
	if (_tmp8_) {
		self->priv->in_button = TRUE;
		contacts_clickable_update_state (self);
	}
	result = FALSE;
	return result;
}


static gboolean contacts_clickable_leave_notify_event (ContactsClickable* self, GdkEventCrossing* event) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GdkEventCrossing _tmp2_ = {0};
	GdkWindow* _tmp3_ = NULL;
	GdkWindow* _tmp4_ = NULL;
	GdkWindow* _tmp5_ = NULL;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp12_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp2_ = *event;
	_tmp3_ = _tmp2_.window;
	_tmp4_ = contacts_clickable_get_event_window (self);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp3_ == _tmp5_;
	_g_object_unref0 (_tmp5_);
	if (_tmp6_) {
		GdkEventCrossing _tmp7_ = {0};
		GdkNotifyType _tmp8_ = 0;
		_tmp7_ = *event;
		_tmp8_ = _tmp7_.detail;
		_tmp1_ = _tmp8_ != GDK_NOTIFY_INFERIOR;
	} else {
		_tmp1_ = FALSE;
	}
	_tmp9_ = _tmp1_;
	if (_tmp9_) {
		GtkWidget* _tmp10_ = NULL;
		gboolean _tmp11_ = FALSE;
		_tmp10_ = self->priv->widget;
		_tmp11_ = gtk_widget_get_sensitive (_tmp10_);
		_tmp0_ = _tmp11_;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp12_ = _tmp0_;
	if (_tmp12_) {
		self->priv->in_button = FALSE;
		contacts_clickable_update_state (self);
	}
	result = FALSE;
	return result;
}


static void contacts_clickable_pressed (ContactsClickable* self) {
	guint _tmp0_ = 0U;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->activate_timeout;
	if (_tmp0_ != ((guint) 0)) {
		return;
	}
	self->priv->button_down = TRUE;
	contacts_clickable_update_state (self);
}


static void contacts_clickable_released (ContactsClickable* self) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->button_down;
	if (_tmp0_) {
		guint _tmp1_ = 0U;
		gboolean _tmp2_ = FALSE;
		self->priv->button_down = FALSE;
		_tmp1_ = self->priv->activate_timeout;
		if (_tmp1_ != ((guint) 0)) {
			return;
		}
		_tmp2_ = self->priv->in_button;
		if (_tmp2_) {
			g_signal_emit_by_name (self, "clicked");
		}
	}
	contacts_clickable_update_state (self);
}


static void contacts_clickable_finish_activate (ContactsClickable* self, gboolean do_it) {
	guint _tmp0_ = 0U;
	GdkDevice* _tmp1_ = NULL;
	GtkWidget* _tmp6_ = NULL;
	gboolean _tmp7_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->activate_timeout;
	g_source_remove (_tmp0_);
	self->priv->activate_timeout = (guint) 0;
	_tmp1_ = self->priv->grab_keyboard;
	if (_tmp1_ != NULL) {
		GdkDevice* _tmp2_ = NULL;
		guint32 _tmp3_ = 0U;
		GtkWidget* _tmp4_ = NULL;
		GdkDevice* _tmp5_ = NULL;
		_tmp2_ = self->priv->grab_keyboard;
		_tmp3_ = self->priv->grab_time;
		gdk_device_ungrab (_tmp2_, _tmp3_);
		_tmp4_ = self->priv->widget;
		_tmp5_ = self->priv->grab_keyboard;
		gtk_device_grab_remove (_tmp4_, _tmp5_);
		_g_object_unref0 (self->priv->grab_keyboard);
		self->priv->grab_keyboard = NULL;
	}
	self->priv->button_down = FALSE;
	contacts_clickable_update_state (self);
	_tmp6_ = self->priv->widget;
	gtk_widget_queue_draw (_tmp6_);
	_tmp7_ = do_it;
	if (_tmp7_) {
		g_signal_emit_by_name (self, "clicked");
	}
}


static gboolean contacts_clickable_activate_timeout_cb (ContactsClickable* self) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	contacts_clickable_finish_activate (self, TRUE);
	result = FALSE;
	return result;
}


static void contacts_clickable_update_state (ContactsClickable* self) {
	gboolean depressed = FALSE;
	guint _tmp0_ = 0U;
	GtkStateFlags new_state = 0;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp11_ = FALSE;
	GtkStateFlags _tmp13_ = 0;
	GtkStateFlags _tmp14_ = 0;
	gboolean _tmp17_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->activate_timeout;
	if (_tmp0_ != ((guint) 0)) {
		gboolean _tmp1_ = FALSE;
		_tmp1_ = self->priv->depress_on_activate;
		depressed = _tmp1_;
	} else {
		gboolean _tmp2_ = FALSE;
		gboolean _tmp3_ = FALSE;
		gboolean _tmp5_ = FALSE;
		_tmp3_ = self->priv->in_button;
		if (_tmp3_) {
			gboolean _tmp4_ = FALSE;
			_tmp4_ = self->priv->button_down;
			_tmp2_ = _tmp4_;
		} else {
			_tmp2_ = FALSE;
		}
		_tmp5_ = _tmp2_;
		depressed = _tmp5_;
	}
	new_state = 0;
	_tmp6_ = self->priv->in_button;
	if (_tmp6_) {
		GtkStateFlags _tmp7_ = 0;
		_tmp7_ = new_state;
		new_state = _tmp7_ | GTK_STATE_FLAG_PRELIGHT;
	}
	_tmp9_ = self->priv->button_down;
	if (_tmp9_) {
		_tmp8_ = TRUE;
	} else {
		gboolean _tmp10_ = FALSE;
		_tmp10_ = depressed;
		_tmp8_ = _tmp10_;
	}
	_tmp11_ = _tmp8_;
	if (_tmp11_) {
		GtkStateFlags _tmp12_ = 0;
		_tmp12_ = new_state;
		new_state = _tmp12_ | GTK_STATE_FLAG_ACTIVE;
	}
	_tmp13_ = new_state;
	_tmp14_ = self->state;
	if (_tmp13_ != _tmp14_) {
		GtkStateFlags _tmp15_ = 0;
		GtkWidget* _tmp16_ = NULL;
		_tmp15_ = new_state;
		self->state = _tmp15_;
		_tmp16_ = self->priv->widget;
		gtk_widget_queue_resize (_tmp16_);
	}
	_tmp17_ = depressed;
	contacts_clickable_set_depressed (self, _tmp17_);
}


static void contacts_clickable_state_changed (ContactsClickable* self, GtkStateType previous_state) {
	GtkWidget* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->widget;
	_tmp1_ = gtk_widget_is_sensitive (_tmp0_);
	if (!_tmp1_) {
		self->priv->in_button = FALSE;
		contacts_clickable_released (self);
	}
}


static void contacts_clickable_grab_notify (ContactsClickable* self, gboolean was_grabbed) {
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	guint _tmp2_ = 0U;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp2_ = self->priv->activate_timeout;
	if (_tmp2_ != ((guint) 0)) {
		GdkDevice* _tmp3_ = NULL;
		_tmp3_ = self->priv->grab_keyboard;
		_tmp1_ = _tmp3_ != NULL;
	} else {
		_tmp1_ = FALSE;
	}
	_tmp4_ = _tmp1_;
	if (_tmp4_) {
		GtkWidget* _tmp5_ = NULL;
		GdkDevice* _tmp6_ = NULL;
		gboolean _tmp7_ = FALSE;
		_tmp5_ = self->priv->widget;
		_tmp6_ = self->priv->grab_keyboard;
		_tmp7_ = gtk_widget_device_is_shadowed (_tmp5_, _tmp6_);
		_tmp0_ = _tmp7_;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp8_ = _tmp0_;
	if (_tmp8_) {
		contacts_clickable_finish_activate (self, FALSE);
	}
	_tmp9_ = was_grabbed;
	if (!_tmp9_) {
		gboolean save_in = FALSE;
		gboolean _tmp10_ = FALSE;
		gboolean _tmp11_ = FALSE;
		gboolean _tmp12_ = FALSE;
		_tmp10_ = self->priv->in_button;
		save_in = _tmp10_;
		self->priv->in_button = FALSE;
		contacts_clickable_released (self);
		_tmp11_ = save_in;
		_tmp12_ = self->priv->in_button;
		if (_tmp11_ != _tmp12_) {
			gboolean _tmp13_ = FALSE;
			_tmp13_ = save_in;
			self->priv->in_button = _tmp13_;
			contacts_clickable_update_state (self);
		}
	}
}


static gboolean _contacts_clickable_activate_timeout_cb_gsource_func (gpointer self) {
	gboolean result;
	result = contacts_clickable_activate_timeout_cb (self);
	return result;
}


static void contacts_clickable_real_activate (ContactsClickable* self) {
	GdkDevice* device = NULL;
	GdkDevice* _tmp0_ = NULL;
	GdkDevice* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	GdkDevice* _tmp3_ = NULL;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp10_ = FALSE;
	GtkWidget* _tmp11_ = NULL;
	gboolean _tmp12_ = FALSE;
	gboolean _tmp14_ = FALSE;
	_tmp0_ = gtk_get_current_event_device ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	device = _tmp1_;
	_tmp3_ = device;
	if (_tmp3_ != NULL) {
		GdkDevice* _tmp4_ = NULL;
		GdkInputSource _tmp5_ = 0;
		_tmp4_ = device;
		_tmp5_ = gdk_device_get_source (_tmp4_);
		_tmp2_ = _tmp5_ != GDK_SOURCE_KEYBOARD;
	} else {
		_tmp2_ = FALSE;
	}
	_tmp6_ = _tmp2_;
	if (_tmp6_) {
		GdkDevice* _tmp7_ = NULL;
		GdkDevice* _tmp8_ = NULL;
		GdkDevice* _tmp9_ = NULL;
		_tmp7_ = device;
		_tmp8_ = gdk_device_get_associated_device (_tmp7_);
		_tmp9_ = _g_object_ref0 (_tmp8_);
		_g_object_unref0 (device);
		device = _tmp9_;
	}
	_tmp11_ = self->priv->widget;
	_tmp12_ = gtk_widget_get_realized (_tmp11_);
	if (_tmp12_) {
		guint _tmp13_ = 0U;
		_tmp13_ = self->priv->activate_timeout;
		_tmp10_ = _tmp13_ == ((guint) 0);
	} else {
		_tmp10_ = FALSE;
	}
	_tmp14_ = _tmp10_;
	if (_tmp14_) {
		guint32 time = 0U;
		guint32 _tmp15_ = 0U;
		gboolean _tmp16_ = FALSE;
		GdkDevice* _tmp17_ = NULL;
		gboolean _tmp20_ = FALSE;
		guint _tmp32_ = 0U;
		GtkWidget* _tmp33_ = NULL;
		_tmp15_ = gtk_get_current_event_time ();
		time = _tmp15_;
		_tmp17_ = device;
		if (_tmp17_ != NULL) {
			GdkDevice* _tmp18_ = NULL;
			GdkInputSource _tmp19_ = 0;
			_tmp18_ = device;
			_tmp19_ = gdk_device_get_source (_tmp18_);
			_tmp16_ = _tmp19_ == GDK_SOURCE_KEYBOARD;
		} else {
			_tmp16_ = FALSE;
		}
		_tmp20_ = _tmp16_;
		if (_tmp20_) {
			GdkDevice* _tmp21_ = NULL;
			GdkWindow* _tmp22_ = NULL;
			GdkWindow* _tmp23_ = NULL;
			guint32 _tmp24_ = 0U;
			GdkGrabStatus _tmp25_ = 0;
			gboolean _tmp26_ = FALSE;
			_tmp21_ = device;
			_tmp22_ = contacts_clickable_get_event_window (self);
			_tmp23_ = _tmp22_;
			_tmp24_ = time;
			_tmp25_ = gdk_device_grab (_tmp21_, _tmp23_, GDK_OWNERSHIP_WINDOW, TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK, NULL, _tmp24_);
			_tmp26_ = _tmp25_ == GDK_GRAB_SUCCESS;
			_g_object_unref0 (_tmp23_);
			if (_tmp26_) {
				GtkWidget* _tmp27_ = NULL;
				GdkDevice* _tmp28_ = NULL;
				GdkDevice* _tmp29_ = NULL;
				GdkDevice* _tmp30_ = NULL;
				guint32 _tmp31_ = 0U;
				_tmp27_ = self->priv->widget;
				_tmp28_ = device;
				gtk_device_grab_add (_tmp27_, _tmp28_, TRUE);
				_tmp29_ = device;
				_tmp30_ = _g_object_ref0 (_tmp29_);
				_g_object_unref0 (self->priv->grab_keyboard);
				self->priv->grab_keyboard = _tmp30_;
				_tmp31_ = time;
				self->priv->grab_time = _tmp31_;
			}
		}
		_tmp32_ = gdk_threads_add_timeout ((guint) 250, _contacts_clickable_activate_timeout_cb_gsource_func, self);
		self->priv->activate_timeout = _tmp32_;
		self->priv->button_down = TRUE;
		contacts_clickable_update_state (self);
		_tmp33_ = self->priv->widget;
		gtk_widget_queue_draw (_tmp33_);
	}
	_g_object_unref0 (device);
}


static void contacts_clickable_class_init (ContactsClickableClass * klass) {
	contacts_clickable_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ContactsClickablePrivate));
	CONTACTS_CLICKABLE_CLASS (klass)->activate = contacts_clickable_real_activate;
	G_OBJECT_CLASS (klass)->finalize = contacts_clickable_finalize;
	g_signal_new ("clicked", CONTACTS_TYPE_CLICKABLE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	g_signal_new ("activate", CONTACTS_TYPE_CLICKABLE, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ContactsClickableClass, activate), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void contacts_clickable_instance_init (ContactsClickable * self) {
	self->priv = CONTACTS_CLICKABLE_GET_PRIVATE (self);
}


static void contacts_clickable_finalize (GObject* obj) {
	ContactsClickable * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_CLICKABLE, ContactsClickable);
	_g_object_unref0 (self->priv->widget);
	_g_object_unref0 (self->priv->grab_keyboard);
	_g_object_unref0 (self->priv->event_window);
	G_OBJECT_CLASS (contacts_clickable_parent_class)->finalize (obj);
}


GType contacts_clickable_get_type (void) {
	static volatile gsize contacts_clickable_type_id__volatile = 0;
	if (g_once_init_enter (&contacts_clickable_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ContactsClickableClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_clickable_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsClickable), 0, (GInstanceInitFunc) contacts_clickable_instance_init, NULL };
		GType contacts_clickable_type_id;
		contacts_clickable_type_id = g_type_register_static (G_TYPE_OBJECT, "ContactsClickable", &g_define_type_info, 0);
		g_once_init_leave (&contacts_clickable_type_id__volatile, contacts_clickable_type_id);
	}
	return contacts_clickable_type_id__volatile;
}



