/* display-view.c generated by valac 0.56.3, the Vala compiler
 * generated from display-view.vala, do not modify */

/* display-view.vala
 *
 * Copyright (C) Red Hat, Inc
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 * Author: Felipe Borges <felipeborges@gnome.org>
 *
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <cairo-gobject.h>
#include <float.h>
#include <math.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>

#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 CONNECTIONS_TYPE_DISPLAY_VIEW (connections_display_view_get_type ())
#define CONNECTIONS_DISPLAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_DISPLAY_VIEW, ConnectionsDisplayView))
#define CONNECTIONS_DISPLAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_DISPLAY_VIEW, ConnectionsDisplayViewClass))
#define CONNECTIONS_IS_DISPLAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_DISPLAY_VIEW))
#define CONNECTIONS_IS_DISPLAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_DISPLAY_VIEW))
#define CONNECTIONS_DISPLAY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_DISPLAY_VIEW, ConnectionsDisplayViewClass))

typedef struct _ConnectionsDisplayView ConnectionsDisplayView;
typedef struct _ConnectionsDisplayViewClass ConnectionsDisplayViewClass;
typedef struct _ConnectionsDisplayViewPrivate ConnectionsDisplayViewPrivate;

#define CONNECTIONS_TYPE_CONNECTION (connections_connection_get_type ())
#define CONNECTIONS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnection))
#define CONNECTIONS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnectionClass))
#define CONNECTIONS_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_CONNECTION))
#define CONNECTIONS_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_CONNECTION))
#define CONNECTIONS_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnectionClass))

typedef struct _ConnectionsConnection ConnectionsConnection;
typedef struct _ConnectionsConnectionClass ConnectionsConnectionClass;
enum  {
	CONNECTIONS_DISPLAY_VIEW_0_PROPERTY,
	CONNECTIONS_DISPLAY_VIEW_NUM_PROPERTIES
};
static GParamSpec* connections_display_view_properties[CONNECTIONS_DISPLAY_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block5Data Block5Data;
#define _g_free0(var) (var = (g_free (var), NULL))

#define CONNECTIONS_TYPE_APPLICATION (connections_application_get_type ())
#define CONNECTIONS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_APPLICATION, ConnectionsApplication))
#define CONNECTIONS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_APPLICATION, ConnectionsApplicationClass))
#define CONNECTIONS_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_APPLICATION))
#define CONNECTIONS_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_APPLICATION))
#define CONNECTIONS_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_APPLICATION, ConnectionsApplicationClass))

typedef struct _ConnectionsApplication ConnectionsApplication;
typedef struct _ConnectionsApplicationClass ConnectionsApplicationClass;

#define CONNECTIONS_TYPE_WINDOW (connections_window_get_type ())
#define CONNECTIONS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_WINDOW, ConnectionsWindow))
#define CONNECTIONS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_WINDOW, ConnectionsWindowClass))
#define CONNECTIONS_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_WINDOW))
#define CONNECTIONS_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_WINDOW))
#define CONNECTIONS_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_WINDOW, ConnectionsWindowClass))

typedef struct _ConnectionsWindow ConnectionsWindow;
typedef struct _ConnectionsWindowClass ConnectionsWindowClass;

struct _ConnectionsDisplayView {
	GtkBox parent_instance;
	ConnectionsDisplayViewPrivate * priv;
};

struct _ConnectionsDisplayViewClass {
	GtkBoxClass parent_class;
};

struct _ConnectionsDisplayViewPrivate {
	GtkEventBox* event_box;
	GtkStack* stack;
	GtkLabel* size_label;
	GtkButton* escape_fullscreen_button;
	ConnectionsConnection* connection;
	gulong show_display_id;
	guint size_label_timeout;
	gint width;
	gint height;
};

struct _Block5Data {
	int _ref_count_;
	ConnectionsDisplayView* self;
	GtkWidget* display;
	gulong draw_id;
};

static gint ConnectionsDisplayView_private_offset;
static gpointer connections_display_view_parent_class = NULL;
VALA_EXTERN ConnectionsApplication* connections_application_application;

VALA_EXTERN GType connections_display_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsDisplayView, g_object_unref)
VALA_EXTERN GType connections_connection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsConnection, g_object_unref)
static void connections_display_view_remove_display (ConnectionsDisplayView* self);
VALA_EXTERN void connections_connection_dispose_display (ConnectionsConnection* self);
VALA_EXTERN void connections_display_view_replace_display (ConnectionsDisplayView* self,
                                               ConnectionsConnection* connection);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
VALA_EXTERN GtkWidget* connections_connection_get_widget (ConnectionsConnection* self);
static gboolean __lambda7_ (Block5Data* _data5_);
static gboolean ___lambda7__gtk_widget_draw (GtkWidget* _sender,
                                      cairo_t* cr,
                                      gpointer self);
VALA_EXTERN void connections_display_view_connect_to (ConnectionsDisplayView* self,
                                          ConnectionsConnection* connection);
static void connections_display_view_show_display (ConnectionsDisplayView* self);
static void _connections_display_view_show_display_connections_connection_show (ConnectionsConnection* _sender,
                                                                         gpointer self);
VALA_EXTERN void connections_connection_connect_it (ConnectionsConnection* self);
static gboolean connections_display_view_on_event_box_event (ConnectionsDisplayView* self,
                                                      GdkEvent* event);
static gboolean _connections_display_view_on_event_box_event_gtk_widget_event (GtkWidget* _sender,
                                                                        GdkEvent* event,
                                                                        gpointer self);
static void connections_display_view_on_size_allocate (ConnectionsDisplayView* self,
                                                GtkAllocation* allocation);
static gboolean __lambda8_ (ConnectionsDisplayView* self);
static gboolean __lambda9_ (ConnectionsDisplayView* self);
static gboolean ___lambda9__gsource_func (gpointer self);
static gboolean ___lambda8__gsource_func (gpointer self);
static void _connections_display_view_on_size_allocate_gtk_widget_size_allocate (GtkWidget* _sender,
                                                                          GtkAllocation* allocation,
                                                                          gpointer self);
static void connections_display_view_on_escape_fullscreen_button_clicked (ConnectionsDisplayView* self);
VALA_EXTERN GType connections_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsApplication, g_object_unref)
VALA_EXTERN GType connections_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsWindow, g_object_unref)
VALA_EXTERN ConnectionsWindow* connections_application_get_main_window (ConnectionsApplication* self);
VALA_EXTERN void connections_window_set_fullscreened (ConnectionsWindow* self,
                                          gboolean value);
static void _connections_display_view_on_escape_fullscreen_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                       gpointer self);
static gboolean connections_display_view_real_motion_notify_event (GtkWidget* base,
                                                            GdkEventMotion* event);
VALA_EXTERN gboolean connections_window_get_fullscreened (ConnectionsWindow* self);
VALA_EXTERN ConnectionsDisplayView* connections_display_view_new (void);
VALA_EXTERN ConnectionsDisplayView* connections_display_view_construct (GType object_type);
static GObject * connections_display_view_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties);
static void connections_display_view_finalize (GObject * obj);
static GType connections_display_view_get_type_once (void);

static inline gpointer
connections_display_view_get_instance_private (ConnectionsDisplayView* self)
{
	return G_STRUCT_MEMBER_P (self, ConnectionsDisplayView_private_offset);
}

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

static void
connections_display_view_remove_display (ConnectionsDisplayView* self)
{
	GtkWidget* widget = NULL;
	GtkEventBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	ConnectionsConnection* _tmp6_;
	ConnectionsConnection* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->event_box;
	_tmp1_ = gtk_bin_get_child ((GtkBin*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	widget = _tmp2_;
	_tmp3_ = widget;
	if (_tmp3_ != NULL) {
		GtkEventBox* _tmp4_;
		GtkWidget* _tmp5_;
		_tmp4_ = self->priv->event_box;
		_tmp5_ = widget;
		gtk_container_remove ((GtkContainer*) _tmp4_, _tmp5_);
	}
	_tmp6_ = self->priv->connection;
	if (_tmp6_ == NULL) {
		_g_object_unref0 (widget);
		return;
	}
	_tmp7_ = self->priv->connection;
	connections_connection_dispose_display (_tmp7_);
	_g_object_unref0 (self->priv->connection);
	self->priv->connection = NULL;
	_g_object_unref0 (widget);
}

static Block5Data*
block5_data_ref (Block5Data* _data5_)
{
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}

static void
block5_data_unref (void * _userdata_)
{
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		ConnectionsDisplayView* self;
		self = _data5_->self;
		_g_object_unref0 (_data5_->display);
		_g_object_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}

static gboolean
__lambda7_ (Block5Data* _data5_)
{
	ConnectionsDisplayView* self;
	GtkWidget* _tmp0_;
	gboolean result;
	self = _data5_->self;
	_tmp0_ = _data5_->display;
	g_signal_handler_disconnect ((GObject*) _tmp0_, _data5_->draw_id);
	result = FALSE;
	return result;
}

static gboolean
___lambda7__gtk_widget_draw (GtkWidget* _sender,
                             cairo_t* cr,
                             gpointer self)
{
	gboolean result;
	result = __lambda7_ (self);
	return result;
}

void
connections_display_view_replace_display (ConnectionsDisplayView* self,
                                          ConnectionsConnection* connection)
{
	Block5Data* _data5_;
	GtkEventBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	ConnectionsConnection* _tmp4_;
	GtkWidget* _tmp5_;
	GtkWidget* _tmp6_;
	GtkWidget* _tmp7_;
	GtkWidget* _tmp8_;
	GtkWidget* _tmp9_;
	GtkEventBox* _tmp10_;
	GtkWidget* _tmp11_;
	GtkEventBox* _tmp12_;
	GtkWidget* _tmp13_;
	gulong _tmp14_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (connection != NULL);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_data5_->self = g_object_ref (self);
	_tmp0_ = self->priv->event_box;
	_tmp1_ = gtk_bin_get_child ((GtkBin*) _tmp0_);
	_tmp2_ = connections_connection_get_widget (connection);
	_tmp3_ = _tmp2_;
	if (_tmp1_ == _tmp3_) {
		block5_data_unref (_data5_);
		_data5_ = NULL;
		return;
	}
	connections_display_view_remove_display (self);
	_tmp4_ = _g_object_ref0 (connection);
	_g_object_unref0 (self->priv->connection);
	self->priv->connection = _tmp4_;
	_tmp5_ = connections_connection_get_widget (connection);
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	_data5_->display = _tmp7_;
	_tmp8_ = _data5_->display;
	_tmp9_ = _data5_->display;
	gtk_widget_set_events (_tmp8_, gtk_widget_get_events (_tmp9_) & (~GDK_POINTER_MOTION_MASK));
	_tmp10_ = self->priv->event_box;
	_tmp11_ = _data5_->display;
	gtk_container_add ((GtkContainer*) _tmp10_, _tmp11_);
	_tmp12_ = self->priv->event_box;
	gtk_widget_show_all ((GtkWidget*) _tmp12_);
	_data5_->draw_id = (gulong) 0;
	_tmp13_ = _data5_->display;
	_tmp14_ = g_signal_connect_data (_tmp13_, "draw", (GCallback) ___lambda7__gtk_widget_draw, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
	_data5_->draw_id = _tmp14_;
	block5_data_unref (_data5_);
	_data5_ = NULL;
}

static void
_connections_display_view_show_display_connections_connection_show (ConnectionsConnection* _sender,
                                                                    gpointer self)
{
	connections_display_view_show_display ((ConnectionsDisplayView*) self);
}

void
connections_display_view_connect_to (ConnectionsDisplayView* self,
                                     ConnectionsConnection* connection)
{
	GtkStack* _tmp0_;
	gulong _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (connection != NULL);
	_tmp0_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp0_, "loading");
	if (self->priv->show_display_id != ((gulong) 0)) {
		ConnectionsConnection* _tmp1_;
		_tmp1_ = self->priv->connection;
		g_signal_handler_disconnect ((GObject*) _tmp1_, self->priv->show_display_id);
		self->priv->show_display_id = (gulong) 0;
	}
	connections_display_view_replace_display (self, connection);
	_tmp2_ = g_signal_connect_object (connection, "show", (GCallback) _connections_display_view_show_display_connections_connection_show, self, 0);
	self->priv->show_display_id = _tmp2_;
	connections_connection_connect_it (connection);
}

static void
connections_display_view_show_display (ConnectionsDisplayView* self)
{
	GtkStack* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp0_, "display");
}

static gboolean
connections_display_view_on_event_box_event (ConnectionsDisplayView* self,
                                             GdkEvent* event)
{
	GtkEventBox* _tmp0_;
	GtkWidget* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	if (event->type == GDK_GRAB_BROKEN) {
		result = FALSE;
		return result;
	}
	_tmp0_ = self->priv->event_box;
	_tmp1_ = gtk_bin_get_child ((GtkBin*) _tmp0_);
	if (_tmp1_ != NULL) {
		GtkWidget* child = NULL;
		GtkEventBox* _tmp2_;
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		gdouble offset_x = 0.0;
		GtkWidget* _tmp5_;
		gdouble offset_y = 0.0;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp15_;
		_tmp2_ = self->priv->event_box;
		_tmp3_ = gtk_bin_get_child ((GtkBin*) _tmp2_);
		_tmp4_ = _g_object_ref0 (_tmp3_);
		child = _tmp4_;
		_tmp5_ = child;
		offset_x = (gtk_widget_get_allocated_width ((GtkWidget*) self) - gtk_widget_get_allocated_width (_tmp5_)) / 2.0;
		_tmp6_ = child;
		offset_y = (gtk_widget_get_allocated_height ((GtkWidget*) self) - gtk_widget_get_allocated_height (_tmp6_)) / 2.0;
		switch (gdk_event_get_event_type (event)) {
			case GDK_MOTION_NOTIFY:
			{
				GdkEventMotion* _tmp7_;
				GdkEventMotion* _tmp8_;
				GdkEventMotion* _tmp9_;
				GdkEventMotion* _tmp10_;
				GdkEventMotion* _tmp11_;
				GdkEventMotion* _tmp12_;
				GdkEventMotion* _tmp13_;
				GdkEventMotion* _tmp14_;
				_tmp7_ = (GdkEventMotion *) (event);
				_tmp8_ = _tmp7_;
				_tmp9_ = (GdkEventMotion *) (event);
				_tmp10_ = _tmp9_;
				_tmp10_->x = _tmp10_->x - offset_x;
				_tmp11_ = (GdkEventMotion *) (event);
				_tmp12_ = _tmp11_;
				_tmp13_ = (GdkEventMotion *) (event);
				_tmp14_ = _tmp13_;
				_tmp14_->y = _tmp14_->y - offset_y;
				break;
			}
			default:
			{
				break;
			}
		}
		_tmp15_ = child;
		gtk_widget_event (_tmp15_, event);
		_g_object_unref0 (child);
	}
	result = FALSE;
	return result;
}

static gboolean
_connections_display_view_on_event_box_event_gtk_widget_event (GtkWidget* _sender,
                                                               GdkEvent* event,
                                                               gpointer self)
{
	gboolean result;
	result = connections_display_view_on_event_box_event ((ConnectionsDisplayView*) self, event);
	return result;
}

static gboolean
__lambda9_ (ConnectionsDisplayView* self)
{
	GtkLabel* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->size_label;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, FALSE);
	self->priv->size_label_timeout = (guint) 0;
	result = FALSE;
	return result;
}

static gboolean
___lambda9__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda9_ ((ConnectionsDisplayView*) self);
	return result;
}

static gboolean
__lambda8_ (ConnectionsDisplayView* self)
{
	GtkLabel* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->size_label;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, TRUE);
	if (self->priv->size_label_timeout != ((guint) 0)) {
		g_source_remove (self->priv->size_label_timeout);
		self->priv->size_label_timeout = (guint) 0;
	}
	self->priv->size_label_timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 3, ___lambda9__gsource_func, g_object_ref (self), g_object_unref);
	result = FALSE;
	return result;
}

static gboolean
___lambda8__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda8_ ((ConnectionsDisplayView*) self);
	return result;
}

static void
connections_display_view_on_size_allocate (ConnectionsDisplayView* self,
                                           GtkAllocation* allocation)
{
	gboolean _tmp0_ = FALSE;
	GtkAllocation _tmp1_;
	GtkAllocation _tmp3_;
	GtkAllocation _tmp4_;
	GtkLabel* _tmp5_;
	GtkAllocation _tmp6_;
	GtkAllocation _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (allocation != NULL);
	_tmp1_ = *allocation;
	if (self->priv->width == _tmp1_.width) {
		GtkAllocation _tmp2_;
		_tmp2_ = *allocation;
		_tmp0_ = self->priv->height == _tmp2_.height;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	_tmp3_ = *allocation;
	self->priv->width = _tmp3_.width;
	_tmp4_ = *allocation;
	self->priv->height = _tmp4_.height;
	_tmp5_ = self->priv->size_label;
	_tmp6_ = *allocation;
	_tmp7_ = *allocation;
	_tmp8_ = g_strdup_printf (_ ("%d×%d"), _tmp6_.width, _tmp7_.height);
	_tmp9_ = _tmp8_;
	gtk_label_set_label (_tmp5_, _tmp9_);
	_g_free0 (_tmp9_);
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda8__gsource_func, g_object_ref (self), g_object_unref);
}

static void
_connections_display_view_on_size_allocate_gtk_widget_size_allocate (GtkWidget* _sender,
                                                                     GtkAllocation* allocation,
                                                                     gpointer self)
{
	connections_display_view_on_size_allocate ((ConnectionsDisplayView*) self, allocation);
}

static void
connections_display_view_on_escape_fullscreen_button_clicked (ConnectionsDisplayView* self)
{
	ConnectionsApplication* _tmp0_;
	ConnectionsWindow* _tmp1_;
	ConnectionsWindow* _tmp2_;
	GtkButton* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = connections_application_application;
	_tmp1_ = connections_application_get_main_window (_tmp0_);
	_tmp2_ = _tmp1_;
	connections_window_set_fullscreened (_tmp2_, FALSE);
	_tmp3_ = self->priv->escape_fullscreen_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp3_, FALSE);
}

static void
_connections_display_view_on_escape_fullscreen_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                  gpointer self)
{
	connections_display_view_on_escape_fullscreen_button_clicked ((ConnectionsDisplayView*) self);
}

static gboolean
connections_display_view_real_motion_notify_event (GtkWidget* base,
                                                   GdkEventMotion* event)
{
	ConnectionsDisplayView * self;
	ConnectionsApplication* _tmp0_;
	ConnectionsWindow* _tmp1_;
	ConnectionsWindow* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GtkButton* _tmp5_;
	gboolean result;
	self = (ConnectionsDisplayView*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = connections_application_application;
	_tmp1_ = connections_application_get_main_window (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = connections_window_get_fullscreened (_tmp2_);
	_tmp4_ = _tmp3_;
	if (!_tmp4_) {
		result = FALSE;
		return result;
	}
	_tmp5_ = self->priv->escape_fullscreen_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp5_, event->y < ((gdouble) 40));
	result = GTK_WIDGET_CLASS (connections_display_view_parent_class)->motion_notify_event ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), event);
	return result;
}

ConnectionsDisplayView*
connections_display_view_construct (GType object_type)
{
	ConnectionsDisplayView * self = NULL;
	self = (ConnectionsDisplayView*) g_object_new (object_type, NULL);
	return self;
}

ConnectionsDisplayView*
connections_display_view_new (void)
{
	return connections_display_view_construct (CONNECTIONS_TYPE_DISPLAY_VIEW);
}

static GObject *
connections_display_view_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ConnectionsDisplayView * self;
	GtkEventBox* _tmp0_;
	parent_class = G_OBJECT_CLASS (connections_display_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONNECTIONS_TYPE_DISPLAY_VIEW, ConnectionsDisplayView);
	_tmp0_ = self->priv->event_box;
	gtk_widget_set_events ((GtkWidget*) _tmp0_, (gint) (GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK));
	return obj;
}

static void
connections_display_view_class_init (ConnectionsDisplayViewClass * klass,
                                     gpointer klass_data)
{
	connections_display_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ConnectionsDisplayView_private_offset);
	((GtkWidgetClass *) klass)->motion_notify_event = (gboolean (*) (GtkWidget*, GdkEventMotion*)) connections_display_view_real_motion_notify_event;
	G_OBJECT_CLASS (klass)->constructor = connections_display_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = connections_display_view_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Connections/ui/display-view.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "event_box", FALSE, ConnectionsDisplayView_private_offset + G_STRUCT_OFFSET (ConnectionsDisplayViewPrivate, event_box));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "stack", FALSE, ConnectionsDisplayView_private_offset + G_STRUCT_OFFSET (ConnectionsDisplayViewPrivate, stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "size_label", FALSE, ConnectionsDisplayView_private_offset + G_STRUCT_OFFSET (ConnectionsDisplayViewPrivate, size_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "escape_fullscreen_button", FALSE, ConnectionsDisplayView_private_offset + G_STRUCT_OFFSET (ConnectionsDisplayViewPrivate, escape_fullscreen_button));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_event_box_event", G_CALLBACK(_connections_display_view_on_event_box_event_gtk_widget_event));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_size_allocate", G_CALLBACK(_connections_display_view_on_size_allocate_gtk_widget_size_allocate));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_escape_fullscreen_button_clicked", G_CALLBACK(_connections_display_view_on_escape_fullscreen_button_clicked_gtk_button_clicked));
}

static void
connections_display_view_instance_init (ConnectionsDisplayView * self,
                                        gpointer klass)
{
	self->priv = connections_display_view_get_instance_private (self);
	self->priv->width = -1;
	self->priv->height = -1;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
connections_display_view_finalize (GObject * obj)
{
	ConnectionsDisplayView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONNECTIONS_TYPE_DISPLAY_VIEW, ConnectionsDisplayView);
	_g_object_unref0 (self->priv->connection);
	G_OBJECT_CLASS (connections_display_view_parent_class)->finalize (obj);
}

static GType
connections_display_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConnectionsDisplayViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) connections_display_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConnectionsDisplayView), 0, (GInstanceInitFunc) connections_display_view_instance_init, NULL };
	GType connections_display_view_type_id;
	connections_display_view_type_id = g_type_register_static (gtk_box_get_type (), "ConnectionsDisplayView", &g_define_type_info, 0);
	ConnectionsDisplayView_private_offset = g_type_add_instance_private (connections_display_view_type_id, sizeof (ConnectionsDisplayViewPrivate));
	return connections_display_view_type_id;
}

GType
connections_display_view_get_type (void)
{
	static volatile gsize connections_display_view_type_id__once = 0;
	if (g_once_init_enter (&connections_display_view_type_id__once)) {
		GType connections_display_view_type_id;
		connections_display_view_type_id = connections_display_view_get_type_once ();
		g_once_init_leave (&connections_display_view_type_id__once, connections_display_view_type_id);
	}
	return connections_display_view_type_id__once;
}

